我已经设置了我的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
时,它执行没有任何错误。
你们知道出了什么问题吗?
我尝试使用您的配置,但它给了我一个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,它应该可以工作!