网站首页 > 技术教程 正文
一:nginx无法解析PHP文件故障
当用Nginx+php-fpm方式使用php的时候,如果访问php文件出现file not found的问题可以用如下方法解决
将root注释掉,并且修改fastcgi_param为SCRIPT_FILENAME $document_root$fastcgi_script_name;
location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
(如果你默认不更改root目录地址,就需要将/scripts改为$document_root
#默认:fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;)
二:root路径不生效问题
配置文件中另加一项location配置参数,如下:
location / {
root /data/www;
index index.html index.php;
}
root path;
设置web资源路径映射;用于指明用户请求的url所对应的本地文件系统上的文档所在目录路径;可用的位置:http, server, location, if in location;
location [ = | ~ | ~* | ^~ ] uri { ... }
Sets configuration depending on a request URI.
在一个server中location配置段可存在多个,用于实现从uri到文件系统的路径映射;ngnix会根据用户请求的URI来检查定义的所有location,并找出一个最佳匹配,而后应用其配置;
=:对URI做精确匹配;例如, http://www.magedu.com/, http://www.magedu.com/index.html
location = / {
...
}
~:对URI做正则表达式模式匹配,区分字符大小写;
~*:对URI做正则表达式模式匹配,不区分字符大小写;
^~:对URI的左半部分做匹配检查,不区分字符大小写;
不带符号:匹配起始于此uri的所有的url;
匹配优先级:=, ^~, ~/~*,不带符号;
root /vhosts/www/htdocs/
http://www.magedu.com/index.html --> /vhosts/www/htdocs/index.html
server {
root /vhosts/www/htdocs/
location /admin/ {
root /webapps/app1/data/
}
}
alias path;
定义路径别名,文档映射的另一种机制;仅能用于location上下文;
注意:location中使用root指令和alias指令的意义不同;
(a) root,给定的路径对应于location中的/uri/左侧的/;
(b) alias,给定的路径对应于location中的/uri/右侧的/;
index file ...;
默认资源;http, server, location;
error_page code ... [=[response]] uri;
Defines the URI that will be shown for the specified errors.
try_files file ... uri;
专注于运维:
- 上一篇: PHPFPM优化(php-fpm性能优化)
- 下一篇: 「服务器」解决PHP高级问题的两大利器
猜你喜欢
- 2024-10-11 浅谈从PHP迁移至Golang(基础篇)(php传值到另一个php)
- 2024-10-11 相同逻辑的php与golang代码效率对比,最好语言落谁家…
- 2024-09-21 Promethues如何监控PHP(prometheus snmp监控)
- 2024-09-21 蓝易云 - 在centos中配置nginx+php的环境教程。
- 2024-09-21 Zabbix运维—监控php-fpm、redis服务
- 2024-09-21 Zabbix 5.2由浅入深之监控php-fpm
- 2024-09-21 PHP-FPM实现性能优化的方法(php-fpm 优化)
- 2024-09-21 PHP-FPM高负载的解决办法(php高负载解决方案)
- 2024-09-21 php-fpm的配置和优化(php-fpm调优)
- 2024-09-21 docker中运行php文件(docker php fpm)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)