Setup vps with nginx and add multiple website

Posted April 1, 2021 298 views

Hi guys, i relative new to this but someone can help me configure a ubuntu 20.04 vps with nginx host multiple website please?
First i want to configure it to acces ipadress/website1 and ipadress/website2 so i can move/duplicate the websites and then to redirect the domain too after i finish configure all.
I tryed many tutorials but didn’t manage to get it done. All i have managed to do is to add website accesed when i type the ip.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @rober7h,

When you install Nginx you get a default file which loads Nginx on your Droplet’s IP address. This file can be found here:


In order to add two new websites to load like - <^>XXX.XXX.XXX.XXX/website1 and XXX.XXX.XXX.XXX/website2 where XXX.XXX.XXX.XXX is your IP address.
First to make sure which is the root folder from which your file is loading files execute the following

grep root /etc/nginx/sites-enabled/default

You’ll get a result like this:

root@ubuntu-s-1vcpu-1gb-nyc1-01:/etc/nginx/sites-enabled# grep root default
        root /var/www/html;

This means your root folder is /var/www/html. In that folder create the folders for your websites like so:

root@ubuntu-s-1vcpu-1gb-nyc1-01:/etc/nginx/sites-enabled# cd /var/www/html
root@ubuntu-s-1vcpu-1gb-nyc1-01:/var/www/html# mkdir -p {website1,website2}
root@ubuntu-s-1vcpu-1gb-nyc1-01:/var/www/html# ls -lah
total 20K
drwxr-xr-x 4 root root 4.0K Apr  1 06:56 .
drwxr-xr-x 3 root root 4.0K Apr  1 06:51 ..
-rw-r--r-- 1 root root  612 Apr  1 06:51 index.nginx-debian.html
drwxr-xr-x 2 root root 4.0K Apr  1 06:56 website1
drwxr-xr-x 2 root root 4.0K Apr  1 06:56 website2

Now inside those two folders create a simple index.html file like so

root@ubuntu-s-1vcpu-1gb-nyc1-01:/var/www/html# echo 'Test website1' > /var/www/html/website1/index.html
root@ubuntu-s-1vcpu-1gb-nyc1-01:/var/www/html# echo 'Test website2' > /var/www/html/website2/index.html

The above commands will just add the text ‘Test website1’ or 'Test website2’ into an index.html file in the location /var/www/html/website[1,2]/index.html.

Now load your websites like so XXX.XXX.XXX.XXX/website1 and XXX.XXX.XXX.XXX/website2 where XXX.XXX.XXX.XXX is your IP address.

That’s it, you are ready to go.


  • Thanks, it worked, i tryed many things but not this :|
    After setting up my websites in these folder i can make some virtual host and redirect domains to these folders?

Hi @rober7h,

Once you are done with the testing and you want to make your websites load with different domains, you’ll need to add configuration files for each website in the /etc/nginx/sites-enabled/ folder.

Luckily, DigitalOcean has a pretty great tutorial on how you can do that. You can check that here:


by Erin Glass
Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. In this guide, we'll discuss how to get Nginx installed on your Ubuntu 20.04 server.