关于nginx location 配置相关资料很多,由于在配置location时候老是出现404 not found,查阅了很多资料,总算是找到了答案。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /hsc {
root /home/hsc/nginx;
index index.html;
}
location / {
root /home/hsc/nginx/hsc;
index index.html index.htm;
}
}解释下:127.0.0.1 会匹配到 location / 然后 root(表示根目录) 为/home/hsc/nginx/hsc 然后nginx 再去找/后面的内容这里为空,所以就找根目录下的内容。
27.0.0.1/hsc 会匹配到 llocation /hsc 然后 root(表示根目录) 为/home/hsc/nginx 然后nginx 再去找/后面的内容这里为hsc这个目录,所以就会切换到/home/hsc/nginx/hsc目录下。
以上就介绍了Nginx location 配置心得,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号