Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to setup virtual hosts without using the sites-enabled and sites-available directories? I am able to setup it up using those 2 directories but since the Centos install doesn't come with them pre installed, I figured there was another way? Thanks!

share|improve this question
up vote 0 down vote accepted

In your nginx.conf file, just include a server block for each "virtual host" you are trying to create.

Your nginx.conf file probably has an include /etc/nginx/sites-enabled/*.conf line which basically says append all of the configs in that directory to the main nginx.conf file. This is usually done so you don't have a massive nginx.conf file that you have to sort through when you have hundreds of sites. If you don't want to create that those directories because centos doesn't make them for you, then you can just put anything that would have gone into one of those directories directly into your nginx.conf file.

server {
   root /www/;

server {
   root /www/;
share|improve this answer
I installed nginx by following a tutorial because I'm still pretty new to Linux and it told me to create the sites-enabled/available directories and to add that include line. My buddy is a sysadmin and he told me I didn't need it, so I wanted to see what he meant. You did a great job of explaining it, I appreciate it. I am going to try and add virtual hosts by just adding another block like you suggested. How did you know to do that? Is it in the documentation or was it just trial and error? I want to be able to figure this stuff out on my own. Thanks again for all your help. – Fr0ntSight Jul 8 '13 at 23:35
It's described in the official documentation at . Also, if the answer helped, then please click the up arrow next to the answer to give it a +1 and mark it as correct. Thanks! – Michael Yasumoto Jul 8 '13 at 23:40
I did the check but it won't let me do the up arrow because i need 15 reputation first. As soon as I have it I will +1 it. Thanks again. – Fr0ntSight Jul 9 '13 at 1:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.