Update Package

sudo apt update

Upgrade Package

sudo apt upgrade 

Install Apache2

sudo apt install apache2 

Activate Apache2 Rules

sudo a2enmod rewrite mod-mime 

Install MySQL

Full guide on installing MySQL on Ubuntu and Debian

sudo apt install mysql-server

Install PHP

sudo apt install php 

Install PHP Module

sudo apt install php-pear php-fpm php-dev php-xdebug php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php libapache2-mod-php php-cli

Allow to run Apache on boot up

sudo systemctl enable apache2 

Restart Apache Web Server

sudo systemctl start apache2

Here is list of commands that you would find useful depending on your usage.

ENABLE MOD_REWRITE ON APACHE

sudo a2enmod rewrite

systemctl restart apache2

To give write permission to the folder
sudo chown -R username /var/www/html/

html $ sudo nano wp-config.php
define(‘FS_METHOD’, ‘direct’);

WordPress and drupal installation – file write permission for apache server
sudo chown -R www-data:www-data /var/www/html

sudo find /var/www/html/wp/ -type d -exec chmod 750 {} \;
sudo find /var/www/html/wp/ -type f -exec chmod 640 {} \;

NetBeans permission
sudo chown -R username:root /var/www/html

MYSQL SERVER on UBUNTU
service mysql status
service mysql stop
service mysql start

RESTART APACHE SERVER ON UBUNTU
systemctl restart apache2

DRUPAL installation
WRITE PERMISION
$ mkdir -p sites/default/files
# chmod to keep write permissions for wodby user
$ chmod 775 sites/default/files
$ chown www-data:www-data sites/default/files