If you want to change default web location path in your Nginx web server, then keep your close attention in this post as I am going to share how to change default web location patient h in Nginx.
Follow the steps to change Nginx default web location path.
1. Open the nginx.conf file.
1 2 3 4 5 6 7 8 | # Default locaction in mac if you have installed it through homebrew: /usr/local/etc/nginx/nginx.conf # Possible locations on Unix or Linux /etc/nginx/nginx.conf /opt/nginx/conf/ |
2. Open nginx.conf file and locate below piece of configuration in file.
1 2 3 4 5 6 7 8 9 | server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } } |
3. Now replace the “html”: with your desired folder location, like “/usr/freewebmentor/html”
1 2 3 4 5 6 7 8 9 | server { listen 80; server_name localhost; location / { root /usr/freewebmentor/html; index index.html index.htm; } } |
4. Now save the all configuration files and restart Nginx using the below command.
1 2 3 | $ sudo nginx -s stop $ sudo nginx |
Hope this tutorial has solve your need like how to change nginx default folder, how to change nginx default page, how to edit nginx configuration file, how to change nginx default port, etc…
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.