Using this tutorial https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3, I’m trying to set up virtual hosts with nginx to have multiple static sites on Digital Ocean.
I created the first virtual host using my IP address without a problem i.e. when I went to my ip address, I got the hello world message “Success, you have set up virtual host” created in the tutorial.
At the bottom of the tutorial, it says to go through the same process again to create more virtual hosts (i.e. to host other domains). Therefore, I went through the process again to host a domain whose nameservers I have pointed to digital ocean, however, I found certain steps confusing when trying to duplicate the process and when I tried to restart nginx I got this error
sudo service nginx restart Restarting nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 nginx: configuration file /etc/nginx/nginx.conf test failed
It started getting confusing the second time around when I got to step four, “Create the New Virtual Host File”. I did this (replacing example.com) with my domain name
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
However, the instructions make clear that I have to create a new virtual host file each time, so I think I did that correctly.
At Step 5, I did this (replacing example.com with my domain name)
sudo nano /etc/nginx/sites-available/example.com
and then added the information the tutorial specified into the file.
Then I did this (replacing example.com with my domain name)
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
Then I didn’t do the next step because I already removed the default when I created the first virtual host using my ip address
sudo rm /etc/nginx/sites-enabled/default
Afterwards I restarted nginx and got the error I referred to above
Restarting nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 nginx: configuration file /etc/nginx/nginx.conf test failed
Now when I visit the ip address (which worked before) I’m getting this message
The requested URL could not be retrieved
While trying to retrieve the URL: http://184.108.40.206/
The following error was encountered:
Connection to 220.127.116.11 Failed The system returned:
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.
Click below to sign up and get $100 of credit to try our products over 60 days!