conf /etc/nginx/sites-enabled/test.
💡 Nginx on Linux makes use of symlinks in a smart way to enable site configurations. 👉🏼 "sites-available" folder holds all your site configurations. In the "sites-enabled" folder you create symlinks to the previous folder for the sites you wish to enable.
The difference is that virtual sites listed in the sites-enabled directory are served by Apache. In the sites-available directory there are the virtual sites that exist on your server, but people can't access them because they are not enabled yet.
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 the http block inside /etc/nginx/nginx.conf and add this line
include /etc/nginx/sites-enabled/*;
Of course, all the files will be inside sites-available, and you'd create a symlink for them inside sites-enabled for those you want enabled.
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 the conf.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 directory conf.d.Any .conf files that you put into the conf.d directory from here on out will become active as long as you reload/restart nginx after.
Note: You can use the conf.d and sites-enabled + sites-available method concurrently if you wish. I like to test on my dev box using conf.d. Feels faster than symlinking and unsymlinking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With