Here you will see the basics of setting un an Apache Web Server on Ubuntu 18.04

Installation

To start follow the Ubuntu server installation here

To start install ubuntu and openssh server. Then connect to it.

OK let’s start :

Start by updating everything :

sudo apt update && sudo apt upgrade && sudo apt autoremove && sudo reboot now

sudo apt install apache2

sudo apt install php7.2

sudo apt install mysql-server

sudo mysql_secure_installation

Setting permissions

First, you should ensure that your username is included in www-data group. If not, you can add your username as www-data group

sudo adduser $USER www-data

After that, you should change the ownership of /var/www to your username

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

Next step, for general practice, you should change permission to 755 (rwxr-xr-x), not recommend changing permission to 777 for security reason

sudo chmod u=rwX,g=srX,o=rX -R /var/www

Related to specific permission for wordpress or laravel or another framework, then you can read the documentation respectively.

sudo a2enmod rewrite

systemctl restart apache2

Additional modules

sudo apt install php7.2-mysql && sudo apt install php7.2-curl && sudo apt install -y php7.2-mailparse && sudo apt install php7.2-mysql && sudo apt install php7.2-imap && sudo apt install php7.2-gd && sudo apt install php7.2-intl

Now restart apache service :
sudo service apache2  restart

To see the installed modules : php -m

Adding a user and database to mysql

sudo mysql -u root

CREATE DATABASE livres DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

GRANT ALL PRIVILEGES ON *.* TO 'usr'@'localhost' IDENTIFIED BY 'pass';

For more commands please refer to my page with all of the useful mysql commands