加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

在nginx和php上访问被拒绝

发布时间:2020-05-23 01:21:47 所属栏目:Nginx 来源:互联网
导读:使用nginx web服务器和php. nginx正在工作,我看到欢迎来到nginx!但是在尝试访问php页面时我得到“访问被拒绝”.我还安装了php-fastcgi.这是我的nginx默认conf:# redirect server error pages to the static page /50x.html # error_page 500

使用nginx web服务器和php. nginx正在工作,我看到’欢迎来到nginx!’但是在尝试访问php页面时我得到“访问被拒绝”.我还安装了php-fastcgi.

这是我的nginx默认conf:

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php${
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php${
    root   /usr/share/nginx/html;
    fastcgi_index  index.php;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
   # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    include        fastcgi_params;
}

# deny access to .htaccess files,if Apache's document root
# concurs with nginx's one
#
location ~ /.ht {
    deny  all;
}

我在/etc/php-fpm.d/www.conf中激活了security.limit_extensions = .php .php3 .php4 .php5 .html和listen = /var/run/php5-fpm.sock,在/中激活了cgi.fix_pathinfo = 0等/ PHP5 / FPM / php.ini中

我重启了nginx和php5-fpm.

谢谢你的帮助.

最佳答案 如果您有次要位置,请这样做

location / {

        try_files $uri $uri/ =404;  

        root /path/to/your/www;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

        fastcgi_param   PATH_INFO         $fastcgi_path_info;
            fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name;

    }

这两个参数是魔术酱:

fastcgi_param   PATH_INFO         $fastcgi_path_info;
fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name;

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读