Configure SSL Apache on Ubuntu…

Spread the love
Generate a Self-Signed Certificate:-

 $a2enmod ssl 
$mkdir /etc/apache2/ssl 
$openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/ssl.pem -keyout /etc/apache2/ssl/ssl.key

You will be asked for several configuration values. Enter values appropriate for your organization and server, as shown here.

Generating a 1024 bit RSA private key
.++++++
…………………………++++++
writing new private key to ‘/etc/apache2/ssl/ssl.key’
—–
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]:Gujarat
Locality Name (eg, city) []:Ahmedabad
Organization Name (eg, company) [Internet Widgits Pty Ltd]:VishalVyas Ltd
Organizational Unit Name (eg, section) []:Web Dept
Common Name (eg, YOUR name) []:Vishal Vyas
Email Address []:vishal.gtpl@gmail.com

Open /etc/apache2/ports.conf
NameVirtualHost 192.168.1.1:443
or
NameVirtualHost *:443

Replace “192.168.1.1” with your Linode’s IP address.

Now open Apache virtual hosting file

vim /etc/apache2/sites-available/vishalvyas.com

<VirtualHost *:443>  Or  <VirtualHost 192.168.1.1:443>
     SSLEngine On
     SSLCertificateFile /etc/apache2/ssl/ssl.pem
     SSLCertificateKeyFile /etc/apache2/ssl/ssl.key
   ServerAdmin info@vishalvyas.com
   ServerName vishalvyas.com
   DocumentRoot /var/www/html/vishal
 </VirtualHost>

Restart Apache:

/etc/init.d/apache2 restart

You should now be able to visit your site with SSL enabled (after accepting your browser’s warnings about the certificate).

Thanks,
Vishal

Linuxguru

Leave a Comment

PHP Code Snippets Powered By : XYZScripts.com