PHP 网站如何修改默认访问文件的nginx配置-实例分析

墨辰丷
墨辰丷 原创
2023-03-27 11:04:01 1117浏览

这篇文章主要介绍了PHP 网站修改默认访问文件的nginx配置,需要的朋友可以参考下

搭建好lnmp后,有时候并不需要直接访问index.php,配置其他的默认访问文件比如index.html这时候需要配置一下nginx才能访问到你想要设置的文件

直接上代码,如下是我的配置的一份简单的nginx到php-fpm的站点,该站点默认访问目录/ecmoban/www/index.html

server {
listen 80;
location / {
root /ecmoban/www;
index index.html index.php index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /ecmoban/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

相关推荐:

nginx内php动态裁剪图片步骤详解

php nginx实现实时输出步骤详解

Nginx+PHP-FPM的优化技巧

以上就是PHP 网站如何修改默认访问文件的nginx配置-实例分析的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。