xiaotanggao 2022-03-02 14:16 采纳率: 85.7%
浏览 18
已结题

php-fpm 正常启动,浏览器访问却找不到文件

问题遇到的现象和发生背景

访问index.html正常,访问index.php找不到文件

img

img

问题相关代码,请勿粘贴截图
php-fpm正常启动
[root@nginx sbin]# ps -ef |grep php-fpm
root      95107      1  0 15:55 ?        00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
www       95108  95107  0 15:55 ?        00:00:00 php-fpm: pool www
www       95109  95107  0 15:55 ?        00:00:00 php-fpm: pool www
root      95239  24085  0 16:12 pts/0    00:00:00 grep --color=auto php-fpm

nginx配置文件
[root@nginx sbin]# cat /usr/local/nginx/conf/nginx.conf

    server {
        listen       80;
        server_name  192.168.139.102;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #root   /usr/local/nginx/html/wordpress;
root   html;
        location / {
            #root   html;
            #root   /usr/local/nginx/html/wordpress;
            index  index.html index.htm readme.html;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location ~ \.php$ {
        #    root           /usr/local/nginx/html/wordpress;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

测试用代码
[root@nginx sbin]# cat /usr/local/nginx/html/index.php 
<?php
    phpinfo();
?>

我想要达到的结果

不知道什么原因

  • 写回答

1条回答 默认 最新

  • IT民工金鱼哥 运维领域新星创作者 2022-03-02 14:31
    关注

    你的文件读取都没有启用,最关键,php的根目录又没指定,人家怎么去找呢?
    例如一个常规设置如下:

        server {
            #监听端口
            listen 80;
            server_name xxxx.com;
            index index.html index.htm index.php;
    。。。。。
             location ~ \.php$ {
                 root           /usr/local/nginx/html;
                 fastcgi_pass   127.0.0.1:9000;
                 fastcgi_index  index.php;
                 fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
                 include        fastcgi_params;
             }
    

    在很多位置,都没有看到你启用 index.php 这个,又没看到找哪里目录。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 3月10日
  • 已采纳回答 3月2日
  • 创建了问题 3月2日

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算