I installed Nginx on Centos 6 and I am trying to set up virtual hosts. The problem I am having is that I can't seem to find the /etc/nginx/sites-available
directory.
Is there something I need to do in order to create it? I know Nginx is up and running because I can browse to it.
If you'd prefer a more direct approach, one that does NOT mess with symlinking between
/etc/nginx/sites-available
and/etc/nginx/sites-enabled
, do the following:/etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
This tells nginx to pull in any files in theconf.d
directory that end in.conf
. (I know: it's weird that a directory can have a.
in it.)conf.d
directory if it doesn't already exist (per the path in step 3). Be sure to give it the right permissions/ownership. Likely root or www-data./etc/nginx/sites-available
) into the directoryconf.d
.Any
.conf
files that you put into theconf.d
directory from here on out will become active as long as you reload/restart nginx after.Note: You can use the
conf.d
andsites-enabled
+sites-available
method concurrently if you wish. I like to test on my dev box usingconf.d
. Feels faster than symlinking and unsymlinking.Well, I think nginx by itself doesn't have that in its setup, because the Ubuntu-maintained package does it as a convention to imitate Debian's apache setup. You could create it yourself if you wanted to emulate the same setup.
Create
/etc/nginx/sites-available
and/etc/nginx/sites-enabled
and then edit thehttp
block inside/etc/nginx/nginx.conf
and add this lineOf course, all the files will be inside
sites-available
, and you'd create a symlink for them insidesites-enabled
for those you want enabled.