-
Nginx下zend framework的设置
Posted on 九月 25th, 2008 4 comments在Linux环境下增加一段虚拟服务器的设置,设置nginx.conf如下
server {
listen 80;
server_name audit.local;
root /app/audit/public;
access_log /app/audit/logs/audit.access.log main;
error_log /app/audit/logs/audit.error.log;
location / {
index index.php;
# If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?$1& last;
}
}
location ~* ^.+\.(js|ico|gif|jpg|jpeg|pdf|png|css)$ {
access_log off;
expires 7d;
}
location ~ .*\.php?$ {
fastcgi_pass 127.0.0.1:36;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 http://audit.local/error;
}
你也可以参考apache下zend framework的设置。4 responses to “Nginx下zend framework的设置”
-
qingyue 八月 29th, 2009 10:46
rewrite ^/(.+)$ /index.php?$1& last;
这个重写规则应用后,常规的图片、css、js都并不能访问了。 -
inetdemon 八月 31st, 2009 15:49
看你的目录怎么安排了,请注意下面第一句的意思是原目录下面文件或者目录找不到的话再执行重定向,如果找到就执行。如果你的css等目录在根目录下,这么设定就好了。
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?$1& last;
} -
qingyue 九月 1st, 2009 15:16
多谢。
有个问题想请教一下:
location / {
index index.php;
# If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?$1& last;
}
}
把location / 改为 location /test,也就是之让/test有rewrite功能,但是这样其他目录都不能访问了 -
inetdemon 九月 27th, 2009 23:25
Zend framework是单一入口,所有的访问必须先通过index.php。如果你想对其他目录再做静态化,可以在上述规则之外设置nginx的rewrite规则。也可以用Zend framework自己的router来设置,对于访问量不是非常大的应用,建议用router来设置,这样修改方便。
Leave a reply
-

