nginx php-fpm 都已经设置好,访问php页面直接下载文件
PHPz
PHPz 2017-05-16 13:10:34
[PHP讨论组]
    location ~ \.php$ {
        fastcgi_pass   0.0.0.0:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
        include        fastcgi_params;
        break;
    } 
    
    location / { 
        rewrite ^/ /index.php break;
    }  
   
   这样设置 访问php页面会直接下载php文件
   
   但是不重定向
   location / { 
        index index.php
    }  
   就能够正常执行php文件,头都大了,不知道为什么。 
   
PHPz
PHPz

学习是最好的投资!

全部回复(5)
我想大声告诉你

fastcgi_pass 0.0.0.0:9000; 0.0.0.0是什么鬼

PHPz
server {
    listen 80;
    server_name frontend.com;
    index index.html index.php;
    root  /Users/zhgxun/Public/html/php/zoulu/frontend/web;

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php/$1 last;    
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_pass  127.0.0.1:9000;
        include fastcgi.conf;
    }

    access_log  /Users/zhgxun/Public/html/logs/frontend.log  main;
}

我本地使用的配置。

PHP中文网

php-fpm 重启否?

为情所困

建议查看nginx和php的日志来发现问题,

我的conf是这样的:

        location ~* \.php5?$ {
            include        fastcgi_params;
            ##fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass   unix:/usr/local/php5.6/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

另外,你的php-fpm进程正常么?
$ ps aux|grep 'php-fpm'
21274 user php-fpm: master process (/usr/local/php5.6/etc/php-fpm.conf)
21275 user php-fpm: pool www
21276 user php-fpm: pool www

巴扎黑
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 改成这句,从0.8我用nginx起就一直用这句。
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号