【发布时间】:2016-02-21 02:23:32
【问题描述】:
我在 nginx 网络服务器上运行一个基于 php 的网站(购物中心)。 最近听说 phalcon 是一个非常快速可靠的框架,可以帮助开发者加快开发进程。
所以我想在我的网站上实现它,作为特定服务的子模块开始,因为从头开始很难。
我想在 /var/www 下创建一个子文件夹(比如说“phalcontest”)。
我在谷歌上搜索了这个主题,但我在网上找到的所有(也许?)内容都是将 nginx 服务器设置为 phalcon 项目的专用站点(我的意思是,将“项目”文件夹设置为 web 根目录),让 phalcon 项目与旧的非 phalcon 页面共存毫无意义。
我尝试了类似这样的 nginx 配置,希望没问题:
server {
listen 80;
root /var/www/;
index index.html index.htm index.php;
server_name localhost;
access_log /var/log/nginx/access.log main buffer=16k;
error_log /var/log/nginx/error.log;
location @rewrite {
rewrite ^(.*)$ phalcontest/index.php?_url=$1;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
location /phalcontest {
try_files $uri $uri/ @rewrite;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root /var/www/;
}
}
使“phalcontest”文件夹成为 webroot 下启用 phalcon 的子文件夹。
之后我用 phalcon devtools 创建了 phalcontest,
访问http://localhost/phalcontest/public,显示:
恭喜! 你现在和 Phalcon 一起飞行。伟大的事情即将发生! 该页面位于views/index/index.phtml
但是当我访问http://localhost/phalcontest时,它显示:
Mod-Rewrite 未启用
请在您的网络服务器上启用重写模块以继续
这意味着我做错了什么,我只能通过公共文件夹访问,而不是文件夹本身。
请帮助我如何让 phalcon 与现有的基于 php 的站点一起使用!
【问题讨论】: