Setup apache2 with ssl on ubuntu

First of all we should install apache web server and add mod_ssl
sudo apt-get install apache2
sudo a2enmod ssl

Create folder for storing ssl certificates
sudo mkdir /etc/apache2/ssl
Now we generate self signed certificate for one year
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/server.key -out /etc/apache2/ssl/server.crt
This command will ask you few questions. The most important question is “Common Name” – its FDQN server name (lets imagine that FDQN of your server is
Now lets create config file for new virtual host
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
sudo vi /etc/apache2/sites-available/ssl
Add few lines

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

Now we should activate new site
a2enmod ssl
After all lets restart Apache server
service apache2 restart

Thats all!

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *