Report this

What is the reason for this report?

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

Posted on October 31, 2015

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?



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!

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.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.