由于zf自带的工具,生成的项目都是基于apache的,而nginx和apache的htaccess(即Rewriter规则)又不一样,而我自己又不会配置nginx,因此看到这个文章就复制以下,以备以后采用。
在Linux环境下增加一段虚拟服务器的设置,设置nginx.conf如下
XML/HTML代码
- 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;
- }
原文网址:http://www.jefflei.com/post/34.html
版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"