栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Nginx将.php文件作为下载文件,而不是执行它们

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nginx将.php文件作为下载文件,而不是执行它们

尝试这个:

  1. 编辑
    /etc/nginx/sites-available/default

  2. 取消注释两个侦听行,以使nginx在端口80 IPv4和IPv6上侦听。

    listen   80; ## listen for ipv4; this line is default and implied

    listen [::]:80 default_server ipv6only=on; ## listen for ipv6

  3. 离开
    server_name
    独自

    # Make site accessible (...)

    server_name localhost;

  4. 添加
    index.php
    index

    root /usr/share/nginx/www;

    index index.php index.html index.htm;

  5. 取消评论
    location ~ .php$ {}

```

pass the PHP scripts to FastCGI server listening on (…)

location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
# NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini


 # With php5-cgi alone: #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params;

}
```

  1. 编辑
    /etc/php5/fpm/php.ini
    并确保
    cgi.fix_pathinfo
    设置为
    0

  2. 重新启动Nginx和php5-fpm
    sudo service nginx restart && sudo service php5-fpm restart


我一周前才刚刚开始使用Linux,因此我真的希望能在此方面为您提供帮助。我正在使用nano文本编辑器来编辑文件。如果没有,请运行apt-getinstall nano。Google对它了解更多。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/442871.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号