Apache2.4 – Enable SSL and HTTP to HTTPS redirection

On clean Ubuntu 18.04 installation:

Initial installation: PHP & Apache2


sudo apt-get update

sudo apt-get upgrade

sudo apt-get install php

sudo apt-get install apache2

Enable mod_ssl and mod_rewrite then restart apache


sudo a2enmod ssl

sudo a2enmod rewrite

sudo systemctl restart apache2

Create your site, enable it


sudo nano /etc/apache2/sites-available/my_site.conf

sudo a2ensite my_site

sudo systemctl reload apache2

The content of the site looks like:



  RewriteEngine On
  RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined


  ServerName my_site.pro
  SSLEngine on
  SSLCertificateFile "/etc/ssl/my_site/certificate.crt"
  SSLCertificateKeyFile "/etc/ssl/my_site/private_key.key"

  ServerAdmin info@my_site
  DocumentRoot /var/www/html


 

 

Python 3.6 on Ubuntu 16.04

On Ubuntu 16.04, there is a version of Python installed by default.

You should not uninstall it or it will break your machine.

Install Python 3.6

sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6

Now you can use python 3.6. Check the version by using

python3.6 -V

Install pip for Python 3.6

curl https://bootstrap.pypa.io/get-pip.py | sudo python3.6

Now pip is installed for Python3.6 and can be used to add package to this interpreter.

Install package for Python 3.6

sudo python3.6 -m pip install Flask