› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
angelsky11
V2EX  ›  NGINX

nginx 二级目录无法访问

  •  
  •   angelsky11 · Jan 6, 2015 · 11461 views
    This topic created in 4327 days ago, the information mentioned may be changed or developed.
    刚开始接触这个,在自己的vps ubuntu上架了nginx
    然后在nginx的root目录里放了程序的文件夹aaa
    一开始访问 mydomain/aaa 时提示403错误
    修改了权限以后再次访问
    浏览器自动弹出下载框下载index.php文件
    直接访问 mydomain/aaa/index.php 也是直接下载index文件

    求教是不是我的nginx配置文件出了问题

    谢谢
    9 replies  •  2015-01-06 19:08:09 +08:00
    vilison
    vilison
    Jan 6, 2015 via iPhone
    1
    配置php的运行环境,nginx反向访问
    angelsky11
    angelsky11
    OP
    Jan 6, 2015
    2
    @vilison 这个不太懂啊,能否说的明白点,谢谢了
    vilison
    vilison
    Jan 6, 2015 via iPhone
    3
    服务器上配了Apache 或者 php-fpm没有?
    tuuuz
    tuuuz
    Jan 6, 2015
    4
    不知道能不能解决你的问题:
    [Nginx目录浏览功能] http://blog.licess.com/nginx-autoindex/
    bingx86
    bingx86
    Jan 6, 2015
    5
    配置后端CGI了木有,如php-fpm ?
    lizhijun
    lizhijun
    Jan 6, 2015
    6
    php解析有问题
    hzqim
    hzqim
    Jan 6, 2015
    7
    nginx 默认只解析静态 html ,如果要解析 PHP ,首先要安装 PHP ,之后在server段添加如下代码

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }

    即这个样子:

    server {
    listen 80;
    root your_web_root;
    index index.php index.html index.htm;
    server_name XXX.com;

    location / {
    这里填rewrite lules,如果不需要就留空
    }

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    }
    angelsky11
    angelsky11
    OP
    Jan 6, 2015
    8
    @hzqim 我按照这两篇文章 http://huoding.com/2013/10/23/290 http://www.cnblogs.com/quinnxu/archive/2013/05/08/3066274.html
    里面参考的修改了一下,但是启动好以后再访问还是不行,还是之前的问题,下载index.php文件
    php5-fpm运行正常
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   964 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:51 · PVG 02:51 · LAX 10:51 · JFK 13:51
    ♥ Do have faith in what you're doing.