This tutorial explains how to set up an Apache Virtual Host (VPS) for a particular domain. To add more domains, just repeat the process.
You must install Apache web server before following this tutorial.
The original intention was to find a way to host several Wordpress sites on my local computer at the same time. Eventually I found out that the best option was to set up a local VPS, so that's the reason of this tutorial.
In this tutorial I only explain how to set up a local VPS. If you just want to install Wordpress not using a local VPS, you can find that tutorial here.
In this tutorial I will use example.com as our test domain. If you haven't installed Apache web server yet, follow the tutorial here.
$ sudo mkdir -p /var/www/example.com/public_html$ sudo chown -R $USER:$USER /var/www/example.com/public_html$ sudo chmod -R 755 /var/wwwnano /var/www/example.com/public_html/index.html$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf$ sudo nano /etc/apache2/sites-available/example.com.conf
Edit the file so it ends up like this (I removed all comments for easy of reading):
<VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>$ sudo a2ensite example.com.conf$ sudo a2dissite 000-default.conf$ sudo systemctl restart apache2$ sudo nano /etc/hostsAdd the following line in /etc/hosts file:
192.168.1.56 example.comNote: You can find the IP of your network interface by issuing the command ip a
Go to http://example.com in your browser.
If it works, you can delete now the index.html file and start Wordpress installation.