By m73mitchell
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
ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: http://192.241.133.226/
The following error was encountered:
Connection to 192.241.133.226 Failed The system returned:
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
i have same problem , <br> <br>i created separate file for each virtualhost , domain.com and domain2.com in here /etc/nginx/sites-available <br> <br>and i linked them to /etc/nginx/sites-enabled <br> <br>after adding frist , when i want add more virtualhost nginx start fail
<blockquote>when i want add more virtualhost nginx start fail</blockquote>What error does it output? Check its error logs and see which virtualhost is causing issues.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.