Wednesday, October 10, 2012

Apache + SSL = https

Here all my package are place in /apache directory

cd /apache
echo "Switching OFF httpd"
sleep 2

service httpd stop
chkconfig httpd off

echo "Installing needed packages..."
sleep 2

yum install -y pcre*
yum install -y gcc*
yum install -y libtool
yum install -y mod_ssl
yum install -y openssl*
yum install -y libxml*


echo "Untaring apache..."
sleep 2

tar zxvf httpd-2.4.3.tar.gz
tar zxvf apr-1.4.6.tar.gz
tar zxvf apr-util-1.4.1.tar.gz

cd /apache

echo "Moving APR to directories..."
sleep 2

mv apr-1.4.6 /apache/httpd-2.4.3/srclib/apr
mv apr-util-1.4.1 /apache/httpd-2.4.3/srclib/apr-util

mkdir -p /http
cd httpd-2.4.3
echo "Compiling Apache..."
sleep 2
./configure --prefix=/http/ --enable-module=so --enable-rewrite=shared --with-included-apr --enable-cgi --enable-ssl

echo "Installing Apache..."
make install

sleep 2
echo "Time for manual configuration..."
sleep 2

echo "Creating the SSL certificate and key"
sleep 2
openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
echo "Copying the files to /http/conf"
sleep 2
cp server * /http/conf

echo "configure the ssl in apache"
gedit /http/conf/extra/httpd-ssl.conf

we should edit the ssl conf file to correct certificate and key file

echo "
#SSLEngine on
" >> /http/conf/httpd.conf
tail -n 7 /etc/httpd/conf/httpd.conf >> /http/conf/httpd.conf
gedit /http/conf/httpd.conf

in httpd conf file we need to give the above 3 lines and path to certificate and key .we need to check whether the module is loaded or hashed ,if hashed we need to un hash it
the a proper service restart will ask for password

/http/bin/apachectl restart

No comments:

Post a Comment