Sunday, 9 December 2018

HTTPS with Lets Encrypt on Apache - Configuration

HTTPS with Lets Encrypt on Apache - Configuration
After Lets encrypt has been installed via previous post, we need to configure apache to make it work.

// Change /etc/apache2/apache2.conf.  file or httpd.conf for older version
listen 443 (default https port)

// create ssl default file /etc/apache2/sites-available/000-default-ssl.conf

..virtualhost *443..
  ServerName www.virtualhost1.com
    ServerAdmin webmaster@virtualhost1.com
    DocumentRoot /var/www/html/virtualhost1.com
    ErrorLog /var/log/apache2/virtual.host.error.log
    CustomLog /var/log/apache2/virtual.host.access.log combined
    LogLevel warn
..virtualhost..

// update .htaccess file
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]



No comments:

Post a comment