Host multiple websites on LAMP server debian 9

Uncomment if commented in file /etc/apache2/apache2.conf

IncludeOptional sites-enabled/*.conf

Move default location to defaultsite folder

cd /etc/apache2/sites-available/
sudo cp 000-default.conf 000-default.conf.bak
sudo sed -i 's#DocumentRoot /var/www/html#DocumentRoot /var/www/html/defaultsite#g' 000-default.conf 
cd /var/www/html && sudo mkdir defaultsite
shopt -s extglob # enable extended globbing for next command
sudo mv !(defaultsite) defaultsite
sudo service apache2 restart

Create a new site config

sudo mkdir /var/www/html/anothersite.com
cd /etc/apache2/sites-available/
sudo cp 000-default.conf anothersite.com.conf
sudo sed -i 's/defaultsite/anothersite.com/g' anothersite.com.conf
sudo sed -i 's/error.log/anothersite.com_error.log/g' anothersite.com.conf
sudo sed -i 's/access.log/anothersite.com_access.log/g' anothersite.com.conf
sudo sed -i 's/#ServerName www.example.com/ServerName anothersite.com\n    ServerAlias www.anothersite.com/g' anothersite.com.conf
echo "Hello world!" | sudo tee --append /var/www/html/anothersite.com/index.html
sudo a2ensite anothersite.com
sudo service apache2 restart