加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 运营中心 > Nginx > 正文

在userdir中使用nginx运行Moodle(斜杠参数)

发布时间:2020-11-17 11:36:42 所属栏目:Nginx 来源:互联网
导读:我正在将Moodle(moodle.org)从Apache主机移动到运行Nginx的Ubuntu 12.04 LTS主机.设置主机的方式意味着它将运行相当多的域,其中每个域(或其他站点)将驻留在用户目录中.我用php5-fpm运行Nginx.我找到了很多用于在用户目录中运行php-fpm的配置,这些都可以工作.

我正在将Moodle(moodle.org)从Apache主机移动到运行Nginx的Ubuntu 12.04 LTS主机.设置主机的方式意味着它将运行相当多的域,其中每个域(或其他站点)将驻留在用户目录中.

我用php5-fpm运行Nginx.我找到了很多用于在用户目录中运行php-fpm的配置,这些都可以工作.然而问题是Moodle在PHP中大量使用斜杠参数,导致许多url看起来像这样:

/home/[user]/public_html/theme/image.php/standard/theme/1377637305/favicon

我正在运行这个Nginx配置:

server {
        #listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file,then
                # as directory,then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }


        location ~ ^/~(?

我遇到的问题是这个配置适用于普通的php文件,但不适用于使用斜杠参数的HTTP GET请求.
Nginx错误日志报告php-fpm会像以下那样引发错误:

*615 open() "/home/[user]/public_html/theme/image.php/standard/core/1377637305/moodlelogo" failed (20: Not a directory),

要么

5 FastCGI sent in stderr: "Access to the script '/home/[user]/public_html/lib/javascript.php/1377637305/lib/javascript-static.js' has been denied (see security.limit_extensions)" 

这里出了什么问题? 最佳答案 在使用http://wiki.nginx.org/PHPFcgiExample上的示例配置作为基础后,我找到了一个解决方案.此解决方案还建议(与许多其他示例相反)将php.ini中的cgi.fix_pathinfo设置保持为1.

我没有找到完整的user_dir解决方案,而是选择了硬编码解决方案,因为我还不知道如何使$userdir_user变量在后续正则表达式中工作.

要寻找的第二件事是修复fastcgi_split_path_info.原因是否则用户部分被转换为给予PHP的路径.

server {
    index index.php index.html index.htm;

    location ~ ^/~user(?

(编辑:商洛站长网)

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

    推荐文章
      热点阅读