Step One— Create a New Directory
The first step in creating a virtual host is to a create a directory where we will keep the new website’s information. This location will be your Document Root in the nginx virtual configuration file later on. By adding a -p to the line of code, the command automatically generates all the parents for the new directory.
sudo mkdir -p /var/www/example.com/public_html
You will need to designate an actual DNS approved domain, or an IP address, to test that a virtual host is working. In this tutorial we will use example.com as a placeholder for a correct domain name.
However, should you want to use an unapproved domain name to test the process you will find information on how to make it work on your local computer in Step Six.
Step Two—Grant Permissions
We need to grant ownership of the directory to the right user, instead of just keeping it on the root system. You can replace the “www-data” below with the appropriate username.
sudo chown -R www-data:www-data /var/www/example.com/public_html
Additionally, it is important to make sure that everyone is able to read our new files.
sudo chmod 755 /var/www
Now you are all done with permissions.
Read more