Question

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

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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.

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.