首页 > 系统相关 >Nginx配置后无法解析PHP问题

Nginx配置后无法解析PHP问题

时间:2023-09-27 10:55:19浏览次数:31  
标签:index 解析 nginx server Nginx html location PHP php

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

标签:index,解析,nginx,server,Nginx,html,location,PHP,php
From: https://www.cnblogs.com/csjoz/p/17732164.html

相关文章

  • MongoDB 解析:灵活文档数据库与 Docker Compose 部署
    MongoDB是一款开源、高性能的NoSQL数据库,以其无模式的文档存储格式(BSON)而著称,广泛应用于众多开源项目,包括但不限于Yapi等。它在大规模数据存储和实时数据处理方面表现出色,因此备受青睐。在本文中,我们将深入探讨MongoDB的特性,并详细阐述如何使用DockerCompose轻松部署Mon......
  • 解析几何 | 第 2 版
    \(\boldsymbol{Analytic\Geometry}\text{II}\)bydjs.latestupdateforI:2023.07.03latestupdateforII:2023.09.26构建思路小题一般用几何。下一步:列式方向、条件翻译、计算量预判、二级结论的应用。二级结论有些乱还。资料:\(\elli\)\(nk\)一个不错的视频......
  • thinkphp无法访问控制器如何解决
     TP6在初次安装时创建/app/admin/controller/Index文件时无法访问 默认的thinkphp6只有部分的内置拓展包括:自带的frameworkthinkthinkphp核心驱动think-filesystem文件储存驱动think-helper常用助手库think-orm数据库驱动think-trace页面Trace扩展 安装......
  • gunicorn dango nginx 实现同时处理并发请求
    项目是采用 gunicorndangonginx方式部署的。gunicorn.py采用如下方式配置,workers=1bind='0.0.0.0:8000'backlog=2048timeout=6000keepalive=6000errorlog='../error.log'loglevel='info'logFile='../sys.log'accesslog=......
  • Redis内存碎片:深度解析与优化策略
    本文已收录至GitHub,推荐阅读......
  • 震坤行API接口聚合解析,实现根据ID取商品详情
    震坤行是一个工业品服务平台,提供了API接口供开发者使用。要根据ID获取商品详情,您需要使用震坤行API接口并进行相应的请求。以下是使用震坤行API接口根据ID获取商品详情的示例代码(使用Python编写):pythonimportrequestsimportjson#震坤行API接口地址api_url="htt......
  • 在CentOS系统中安装Nginx
    以下是在CentOS系统中安装Nginx的步骤:1.更新系统软件包:sudoyumupdate2.安装EPEL存储库: sudoyuminstallepel-release3.安装Nginx:sudoyuminstallnginx4.启动Nginx服务:sudosystemctlstartnginx5.设置Nginx服务自启动:sudosystemctlenablenginx6.验证Nginx......
  • 解析es6中let和const并模拟实现私有变量
    使用let和const声明变量早已经习以为常了。笔者作为面试官面试过上百人,能准确理解let/const块级作用域以及的候选人不足一二。本文将深入研究let和const的实现原理,以及多种方式来模拟私有变量,希望本文能给初中级前端小伙伴们一点帮助。一、let和const的实现原理1.1......
  • mac M2 python 逆向解析二维码
    首先使用大家推荐的zbarmacm2python3.8安装无法解析动态库安装arch-arm64brewinstallzbarpython使用frompyzbar.pyzbarimportdecodefromPILimportImageif__name__=='__main__':file='qrcode_prod/492C230613047659_XCXM015492.png'......
  • Windos Nginx开发准备
    1.下载打开nginx.conf#Windows修改第一处log_formatmain'$remote_addr-$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''&qu......