我的相关博文:
【Phalcon】Phalcon在阿里云ecs 的linux环境搭建让你真正搭建起来(phalcon一解析)
【phalcon】完美路由配置 apache nginx
【Phalcon配置】Phalcon 设置输出的编码问题
【Phalcon实现高性能网站】使用Phalcon高性能PHP框架搭建网站 视图之共享模板
【Phalcon实现高性能网站】使用Phalcon高性能PHP框架搭建网站 视图之传递参数
【Phalcon实现高性能网站】使用Phalcon高性能PHP框架搭建网站 资源处理之加载css js资源
【Phalcon实现高性能接口开发】使用Phalcon高性能PHP框架搭建API MVC架构之实现查询版本的接口
当phalcon 在服务器配置完毕后,那么 输入网址
http://www.example.net/项目名/public/?_url=/Base/insert
即可访问控制器里面的方法
以下在centos的linux 环境下 配置 路由分发:
Nginx
server {
listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location /publicsocial/ {
#nginx的重写URL规则 把 /publicsocial/后面的内容 放到了public/index.php?_url=/ 后面
rewrite ^/publicsocial/(.*)$ /publicsocial/public/index.php?_url=/$1;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
}
########################## vhost #############################
include vhost/*.conf;
}
随后重启服务器
重启nginx
[root@root ~]# cd /usr/local/nginx/sbin
[root@root sbin]# ./nginx -s reload
重启php-fpm
[root@root]# /etc/init.d/php-fpm restart
最后输入
http://www.example.net/项目名/Base/insert
完美路由配置完成
Apache
在phalcon目录下创建.htaccess文件加入如下语句 主要作用是指向到public
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]
在public加入如下语句 主要作用是定向赋值给_url
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]