【问题标题】:Phalcon and Nginx return 403?Phalcon 和 Nginx 返回 403?
【发布时间】:2015-10-12 00:43:10
【问题描述】:

我的 Nginx 配置如下:

server {

    listen 80;
    server_name myserver.com;

    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log error;

    index index.php;
    set $root_path '/var/www/webroot/ROOT/public';
    root $root_path;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

并在ROOT 文件夹中安装了 Phalcon。但是,Phalcon 一直显示 403 页面。我在日志中找不到任何错误;我唯一拥有的是当我运行service nginx reload 时会抛出[emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)。但是,当我运行 sudo service nginx reload 时,它执行时没有任何错误。

你们有什么线索吗?

【问题讨论】:

    标签: nginx phalcon


    【解决方案1】:

    我尝试使用您的配置,但它给了我一个 503 错误。

    请尝试以下配置。

    server {
        listen 81;
    
        set $root_path \'/var/www/webroot/ROOT/public\';
    
        root /var/www/webroot/ROOT/public;
    
        index index.php index.html index.htm;
    
        # Make site accessible from http://localhost/
        server_name localhost;
        location /{
            root $root_path;
            index index.php;
    
            if (-f $request_filename) {
                break;
            }
    
            if (!-e $request_filename) {
                rewrite ^(.+)$ /index.php?_url=$1 last;
                break;
            }
        }
    
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index /index.php;
    
            include /etc/nginx/fastcgi_params;
    
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO    $fastcgi_path_info;
            #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    

    如果你正确设置了 nginx、php-fpm 和 phalcon,它应该可以工作!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-21
      • 2022-11-01
      • 2022-07-07
      • 2021-06-27
      • 2019-06-15
      • 2011-03-08
      • 2019-02-28
      • 2023-03-29
      相关资源
      最近更新 更多