Which is the right path to put my sites on CentOS 7 using Nginx?

Posted October 31, 2015 14.2k views
Linux BasicsNginxLEMPDeployment

The default directory for the websites in Nginx is /usr/ share/nginx/html,
but there is a default directory created by CentOS /var/www/html.

So which one should i use? which one is more secure? or best practice?

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.

Submit an Answer
2 answers

The default website directory for your websites using nginx as webserver is /var/www.
There you can create directories for every website you like to run and configure your nginx server using VHOSTs.
There are only some default error and index pages inside /usr/share/nginx/html wich you don’t have to and shouldn’t use. Those are only used when you just installed the nginx package.

@Samuelgozi - There’s really not a “right” or “wrong” directory, so to speak. Different NGINX packages will use various directories ranging from /etc/nginx/html/ to /usr/share/nginx/html/ all the way up to the more custom setups which will use one or more user-defined directories.

Ultimately, you’re free to choose where you place your files, just make sure that the directories have the proper permissions set to allow NGINX to access the files (as well as whatever scripting language you choose to run).

On a personal level, I prefer to use /home/username/[custom-directory-string] where [custom-directory-string] is whatever is applicable to the project or client needs. The /home/ directory is the default home directory on most all OS’s and it’s easily identified when a client is browsing through.