Apache/SSL

Install and Configure Apache2 with PHP5 and SSL Support

Required Packages
apache2 openssl ssl-cert libapache2-mod-php5 php5-cli php5-common php5-cgi

Step 1: generate certificate
For generating certificate Use the following command to generate certificates

You are about to be asked to enter information that will be incorporated into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter ‘.’, the field will be left blank.

Country Name (2 letter code) [AU]:IN State or Province Name (full name) [Some-State]:West Bengal Locality Name (eg, city) []:Kolkata Organization Name (eg, company) [Internet Widgits Pty Ltd]:MAT3 Impex Pvt. Ltd. Organizational Unit Name (eg, section) []:Crypto-Devel Common Name (eg, YOUR name) []:Promathesh Mandal Email Address []:promatesh@mat3impex.com

This will complete the certificate now you need to make sure you have the correct permissions for .pem file if not use the following command to set the correct permissions

Note: For generating a certificate signing request give the following command

Step 2: listen the port
By default the server will listen for incoming HTTP requests on port 80 - and not SSL connections on port 443. So you need to enable SSL support by entering the following entry to the file /etc/apache2/ports.conf save and exit the file.

Step 3: enable SSL support
If you want to enable SSL support for your apache web server you need to use the following command

Module ssl installed; run /etc/init.d/apache2 force-reload to enable. Now you need to restart the apache2 server using the following command

Step 4: configuring SSL Certificate to Virtual Hosts in Apache2
First you need to edit the /etc/apache2/sites-available/default file change to

Now you need to configure Virtual hosts using port 80.

Example
configure Virtual hosts using port 443 the main difference is you need to use the following two lines for each SSL hosts.

Example

Now you need to restart your apache web server using the following command

Sample Files : sample for “ports.conf” file

sample for “default” file