Phalcon和Nginx返回403?

时间:2015-07-22 08:39:09

标签: nginx phalcon

我已将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;
    }
}

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

你们有什么线索有什么问题吗?

1 个答案:

答案 0 :(得分:0)

我已尝试使用您的配置,但它给了我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,它应该可以正常工作!