GNU/Linux {docs}

Local VPS

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.

Create the directory structure and permissions

$ 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/www

Create a demo page for example.com virtual host for testing

nano /var/www/example.com/public_html/index.html

Create a virtual host file

$ 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>

Enable the new virtual host file and disable default virtual host file

$ sudo a2ensite example.com.conf
$ sudo a2dissite 000-default.conf
$ sudo systemctl restart apache2

Set up Local Hosts file

$ sudo nano /etc/hosts

Add the following line in /etc/hosts file: 192.168.1.56 example.com

Note: You can find the IP of your network interface by issuing the command ip a

Test the result

Go to http://example.com in your browser.

If it works, you can delete now the index.html file and start Wordpress installation.

https://drive.google.com/drive/folders/1gauQgHCI5y1BpMbPu4VGZpuzAmaT5e5G