a fast way to install a LAMP server with Let’s Encrypt SSL

This is how i usually create a fast Apache/SSL server….

Parts taken from: https://tecadmin.net/install-lamp-quickly-using-tasksel-on-ubuntu-and-linuxmint/

1) Launch a Ubuntu 18.x LTS from your favorite cloud provider (AWS/Hetzner etc).

2) Then log in and check stuff:

Are we up to date?

# sudo apt-get update
# sudo apt-get dist-upgrade

Install taskel, and LAMP:

# sudo apt install tasksel
# sudo tasksel install lamp-server

Secure mysql and install phpmyadmin (only if you need it!)

# sudo mysql_secure_installation
##Optional:
# sudo apt install phpMyAdmin

Add support for Let’s Encrypt via  certbot

# sudo add-apt-repository ppa:certbot/certbot
# sudo apt install python-certbot-apache

3) Setup your web-hosts

See step 5 here.

# sudo mkdir /var/www/yourdomain
# sudo chown -R $USER:$USER /var/www/yourdomain
# sudo chmod -R 755 /var/www/yourdomain

Put some files in the folder …
Then we need to create the vhost:

# sudo nano /etc/apache2/sites-available/yourdomain.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable your site in Apache

# sudo a2ensite yourdomain.conf
# sudo systemctl restart apache2

Check tat the site works: http://yourdomain.dk. Then we are ready to add a SSL to it:

# sudo certbot --apache -d yourdomain.dk -d www.yourdomain.dk

That’s all..