SSL is important thing for the security for your web application, some of the SSL are paid features, but we can have free SSL provided by Let’s Encrypt. In this article, we're going to try to configure SSL on ubuntu + apache2 server.
1. Install Required Packages
We need two packages in order to start creating SSL certficates, they are certbot
and python3-certbot-apache
.
sudo apt update
sudo apt install certbot python3-certbot-apache
2. Configure Apache2 Virtual Host
in this case, I'm going to try to create a virtual host for magento245.dev.fiko.me. You just need to setup the port 80 and skipping the 443 port.
<VirtualHost *:80>
ServerAdmin hi@fiko.me
DocumentRoot /home/fiko/sites/magento245/pub/
ServerName magento245.dev.fiko.me
<Directory /home/fiko/sites/magento245/pub/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then restart your apache2 by running:
sudo service apache2 restart
3. Install SSL
Once you created the virtual host, try to create the certificate by running:
sudo certbot --apache
Follow the steps, and restart apache2 service.
Preferences: