【发布时间】:2016-01-12 21:42:05
【问题描述】:
我一直在尝试让带有 CakePHP 的 Nginx 运行,但在重写方面没有成功。我已经阅读了大量的文章,并没有发现我的配置文件有任何问题。
Nginx Webroot:/usr/share/nginx/html
CakePHP 安装:/usr/share/nginx/html/cakephp
错误:您的服务器上未正确配置 URL 重写。
- 帮我配置一下
- 我不/不能使用 URL 重写
配置文件:
server {
listen 80;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Deny access to .htaccess files,
location ~ /(\.ht|\.git|\.svn) {
deny all;
}
}
【问题讨论】:
-
什么不起作用?是 /doc/ 位置块吗?
-
Cakephp 将启动其起始页,并显示有关未正确配置重写的错误。结果页面上没有css、图片等。