By Samuelgozi
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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.