我最近在8085端口的nginx上托管了cakefp应用程序。
我重新启动nginx,索引页面加载正常。但每当我点击同一个网站(另一个页面)的某个链接时,网页上什么都没有打印出来。
请告诉我我的nginx设置有什么问题。
这是我的nginx配置文件。
server {
server_name example.com;
root /var/www/html/cakephp/app/webroot;
access_log /var/log/nginx/cakeapp.access.log;
error_log /var/log/nginx/cakeapp.error.log;
listen 8085;
rewrite_log on;
# rewrite rules for cakephp
location / {
index index.php index.html;
# If the file exists as a static file serve it
# directly without running all
# the other rewite tests on it
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
location ~* 'favicon.ico$ {
expires 6m;
}
location ~ ^/img/ {
expires 7d;
}
location ~ '.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi.conf;
fastcgi_param SERVER_NAME $host;
}
location ~ /'.ht {
deny all;
}
}
它的路由与cake php有点不同,请尝试
root DIR/app/webroot/;
location / {
index index.php index.html;
rewrite ^/$ /index.php?url=/;
if (!-e $request_filename) {
rewrite ^(/.*)$ /index.php?url=$1 last;
}
}
我不尝试这段代码,但你可以。