Install LAMP server with Apache, PHP 7, and MySQL on Ubuntu 16.04

apt-get -y install mysql-server mysql-client
apt-get -y install apache2
apt-get -y install php7.0 libapache2-mod-php7.0
systemctl restart apache2
apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache  php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext
systemctl restart apache2

Enable the SSL website in apache

a2enmod ssl
a2ensite default-ssl
systemctl restart apache2

Get a free SSL Certificate from Let’s Encrypt

apt-get -y install python-letsencrypt-apache

Before we can start to create the SSL cert, set the domain name in the vhost configuration file. Open the default vhost file with an editor:

nano /etc/apache2/sites-available/000-default.conf

and add the line:

letsencrypt --apache -d

Let’s encrypt Auto Renewal

crontab -e
0 1 * * * /usr/bin/letsencrypt renew &> /dev/null