Nginx配置后无法解析PHP问题
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name 0775web.com www.0775web.com;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm index.pl;
}
# Load configuration files for the default server block.
#include /etc/nginx/default.d/*.conf;
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /images {
autoindex on;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
systemctl restart nginx
吃井不忘挖水人
于 2019-06-27 13:05:50 发布
5573
收藏 6
分类专栏: nginx 文章标签: nginx 无法解析php
版权
nginx
专栏收录该内容
3 篇文章0 订阅
订阅专栏
配置Nginx服务器之后,打开域名,是直接下载而不是直接打开网页,是因为配置的Nginx无法解析PHP的原因。
根据我出现的问题,我的解决办法如下:
1、打开nginx.conf配置文件,
那个127.0.0.1的端口号是nginx与fastcgi交互的id和端口号,也就是fastcgi监听的端口。
location ~ .php$ 表示匹配到php文件就进行fastcgi操作。
location / {}表示请求根路径时, 都会走这里。第一个u r i 表 示 i n d e x . p h p ( 入 口 文 件 ) , 第 二 个 uri表示index.php(入口文件),第二个uri表示index.php(入口文件),第二个uri表示真实路径,/index.php 表示前面都没有的话访问index.php,$args:所有参数。如果要处理url美化时,必须要配置这里。
2.检查127.0.0.1:9000端口是否处于监听状态,执行netstat -antp | grep 9000,发现并没有被监听,说明需要启动。
3.执行php-cgi -b 127.0.0.1:9000 & 启动之后,在执行netstat -antp结果:
4/重启nginx,问题解决。
————————————————
版权声明:本文为CSDN博主「吃井不忘挖水人」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41399976/article/details/93867910
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
2021-09-27 Vue组件模板形式实现对象数组数据循环为树形结构(实例代码)
2021-09-27 打开画图工具命令
2021-09-27 github