Alibaba Cloud nginx configuration file does not take effect

Research monkey Xiao Liu 2022-08-06 07:53:13 阅读数:302


1. My environment is Alibaba Cloud's Ubuntu system

insert image description here

2. My attempt

tried nginx -s reload to no avail

Tried nginx -c custom configuration file also didn't work

I tried nginx -s stop and then restarted it didn't work
I tried nginx -t and it didn't work

3. Finally found the solution

This blog

Comment out these two lines in the specified configuration file, otherwise the configuration file will not take effect. For example, the configuration file you use is
nginx.conf, then check whether there are these two lines, and if so, please commentoff, otherwise it will not take effect
insert image description here
After my observation conf.d is an empty folder, and there is a link file default in the sites-enabled directory. Only the connection file defalut under site-enabled is posted here. You can see that default is linked to /etc/nginx/sites-available/default file

insert image description here
And after opening this file, we found that all requestsWe will go here first, which means that our configuration file will go to this
root directory first. Due to the longest path first matching principle, root /var/www/html will be loaded before root /, so our configuration file will be loaded first.Will not take effect,
insert image description here
go to /var/www/htmlWe can see that there is an index.nginx-debian.html inside
insert image description here
In other words, only this index.nginx-debian.html is in effect every time

版权声明:本文为[Research monkey Xiao Liu]所创,转载请带上原文链接,感谢。