doutangkao2789 2018-01-07 02:47
浏览 110

使用nginx和php-fpm禁止php目录索引403

I followed the instructions on the arch linux wiki to get a site running using nginx + php and without using apache webserver. For some reason, I'm getting the 403 forbidden error when I try to access the directories that I set up in the nginx config. Here's the config:

server {
  server_name myserver.me;
    location /webmail {
        alias /usr/share/webapps/roundcubemail;
        access_log /var/log/nginx/roundcube_access.log;
        error_log /var/log/nginx/roundcube_error.log;
    }
    # Robots file
    location ~ ^/webmail/robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    # Deny Protected directories 
    location ~ ^/webmail/(config|temp|logs)/ {
         deny all;
    }
    location ~ ^/webmail/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
        deny all;
    }
    location ~ ^/webmail/(bin|SQL)/ {
        deny all;
    }
    # Hide .md files
    location ~ ^/webmail/(.+\.md)$ {
        deny all;
    }
    # Hide all dot files
    location ~ ^/webmail/\. {
        deny all;
        access_log off;
        log_not_found off;
    }
    #Roundcube fastcgi config
    location ~ /webmail(/.*\.php)$ {
        include fastcgi.conf;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_split_path_info ^/webmail/(.+\.php)(/.*)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/webapps/roundcubemail/$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PHP_VALUE open_basedir="/tmp/:/var/cache/roundcubemail:/usr/share/webapps/roundcubemail:/etc/webapps/roundcubemail:/usr/share/pear/:/var/log/roundcubemail";
    }
}

}

Why am I getting this error? It's saying that the directory index is forbidden. I know this is a common problem, but I have little php experience, especially with nginx.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集