/ 中存储网

在Nginx服务器环境中安装cakePHP

2014-04-08 16:09:01 来源:kejihao
cakephp部署在nginx的子目录

cakephp部署在nginx子目录下的rewrite

把app改名成相应的子目录名,两次rewrite

location /subdictionary/ {

index index.php;

if (-e $request_filename) {

break;

}

if (!-e $request_filename) {

rewrite ^/subdictionary/(.+)$ /subdictionary/webroot/$1 last;

break;

}

}

location /subdictionary/webroot/ {

index index.php;

if (-e $request_filename) {

break;

}

if (!-e $request_filename) {

rewrite ^/subdictionary/webroot/(.+)$ /subdictionary/webroot/index.php?url=$1 last;

break;

}

}

cakephp在nginx上部署

因为nginx和apache的rewrite有差异,所以cakephp部署到nginx需要些小调整。

在nginx.conf的server里需添加下面这些

location / {

root /cakephp路径/app/webroot;

index index.php;

if (-e $request_filename) {   #文件或目录存在

break;

}

if (!-e $request_filename) {   #文件或目录不存在

rewrite ^/(.+)$ /index.php?url=$1 last;

break;

}

}

location ~ /.ht {   #禁止.htaccess

deny all;

}