【问题标题】:Deploying concrete5 on nginx在nginx上部署concrete5
【发布时间】:2014-05-21 19:55:43
【问题描述】:

我有一个可在 apache 服务器中“开箱即用”的具体站点。但是我在 nginx 中运行它时遇到了很多麻烦。

以下是我正在使用的nginx配置:

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ index.php;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            fastcgi_pass unix:/tmp/phpfpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            include fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
}

我可以访问主页,但内页有问题。内页显示“拒绝访问”。可能重写不起作用,实际上我认为它查询并尝试直接执行 php 文件,而不是通过具体的调度程序。

我完全迷失在这里。

提前感谢您的帮助。

【问题讨论】:

    标签: configuration url-rewriting nginx concrete5


    【解决方案1】:

    将配置更改为:

    server {
        root /home/test/public;
        index index.php;
    
        access_log /home/test/logs/access.log;
        error_log /home/test/logs/error.log;
    
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.php/$request_uri;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }
    
        # pass the PHP scripts to FastCGI server listening on unix socket
        #
        location ~ \.php($|/) {
                set $script $uri;
                if ($uri ~ "^(.+\.php)(/.+)") {
                        set $script $1;
                }
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$script;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/tmp/phpfpm.sock;
        }
    
        location ~ /\.ht {
                deny  all;
        }
    }
    

    这要归功于他在 serverfault 中提供的 hangover 和 link

    我还是不清楚我做错了什么,也许nginx专家可以帮助我理解。

    【讨论】:

      猜你喜欢
      • 2013-07-04
      • 1970-01-01
      • 2019-02-01
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 2017-04-27
      • 1970-01-01
      相关资源
      最近更新 更多