Installing a LAMP Stack on Ubuntu 18.04

INSTALL APACHE2 AND PHP
# apt install apache2
# apt install php7.4 libapache2-mod-php7.4 php-mysql
# apt install php-curl
# apt install php-json

CHECK APACHE STATUS
# systemctl status apache2.service

INSTALL MYSQL
# apt install mysql-server

RUN THE MYSQL INTERACTIVE SETUP
# mysql_secure_installation

MYSQL SERVER STATE
# service mysql stop|status|start

TEST MYSQL LOGIN
# mysql -u root -p

CREATE WEB FILE DIRECTORY STRUCTURE
# mkdir /var/www/logs
# mkdir /var/www/logs/
# chown -R $USER:$USER /var/www/logs/
# mkdir /var/www/html//

SET PERMISSIONS ON WEB FILES
# chown -R www-data: /var/www/html//

CREATE PORT 80 VIRTUAL HOST FILE
/etc/apache2/sites-available/.conf
Apache Vhost

ENABLE THE CUSTOM VIRTUAL HOST FILE
# a2ensite .conf

DISABLE THE DEFAULT HOST FILE
# a2dissite 000-default.conf

RESTART APACHE
# systemctl restart apache2.service

INSTALL CERTBOT
# snap install core
# snap refresh core
# apt-get remove certbot
# snap install --classic certbot
# ln -s /snap/bin/certbot /usr/bin/certbot

CREATE A CERT
# certbot --apache

DO A TEST RUN OF UPDATING THE CERTIFICATE
# certbot renew --dry-run

After running the "CREATE A CERT", CERTBOT CREATES A NEW 443 VERSION OF THE VHOST FILE
/etc/apache2/sites-available/-le-ssl.conf
Apache Vhost Ssl


5/5 : 1 Vote