Install Apache, MySQL, PHP (LAMP) Stack on Ubuntu

  1. Install Apache

sudo apt update && sudo apt install apache2

  1. Configure Firewall

sudo ufw allow OpenSSH

sudo ufw allow in “Apache Full”

sudo ufw enable

sudo ufw status

  1. Test Apache

sudo service apache2 status

  1. Install MySQL

sudo apt update && sudo apt install mysql-server

sudo service mysql status

  1. MySQL Security

sudo mysql_secure_installation

-> ENTER | Y | Y | Y | Y

sudo mysqladmin -p -u root version

  1. Install PHP

sudo apt update && sudo apt install php libapache2-mod-php php-mysql

php -version

  1. Installing phpMyAdmin

sudo apt update && sudo apt install phpmyadmin php-mbstring

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

sudo a2enconf phpmyadmin.conf

sudo service apache2 reload

  1. Create MySQL User

sudo mysql

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;



  1. Secure PhpMyAdmin

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Alias /your_url /usr/share/phpmyadmin

sudo service apache2 reload

  1. Install ZIP/Unzip

apt-get update

apt-get install zip unzip

  1. Enable .htaacess

sudo apt-get update

sudo a2enmod rewrite

systemctl restart apache2

sudo nano /etc/apache2/sites-enabled/000-default.conf

AllowOverride All

  1. Configure Apache File

sudo nano /etc/apache2/apache2.conf

Options Indexes FollowSymLinks
AllowOverride All
Require all granted

Options -Indexes

ServerSignature Off
ServerTokens Prod

  1. install SSL Certificate

sudo apt update && sudo apt install certbot python3-certbot-apache

sudo certbot –apache

service apache2 restart

  1. Permissions

sudo chown -R www-data:www-data /var/www

What do you think?

Written by My Inquisitor


Leave a Reply

GIPHY App Key not set. Please check settings



How To Install a Free SSL Certificate on DigitalOcean With Apache2

Solved ‘Too many redirects’ in WordPress