简体   繁体   English

在Zend Framwork中使用控制器时出现404-Nginx-Ubuntu 14.04

[英]404 when using a controller in zend framwork - Nginx - ubuntu 14.04

I'm using ubuntu 14.04 and installed Nginx, php5 and Zend framework 1.12, i need to use these three for the project i'm working for. 我正在使用ubuntu 14.04并安装了Nginx,php5和Zend框架1.12,我需要将这三个用于我正在工作的项目。 when i try to access the index (localhost) it load immediately, but when i try to access a controller like localhost/Guestbook (from the guide at their page) i get a 404 error. 当我尝试访问索引(localhost)时,它将立即加载,但是当我尝试访问localhost / Guestbook之类的控制器(来自其页面上的指南)时,出现404错误。 I've tried using different controllers and different projects and it's all the same, the main page load fine but i cant get access any controller 我尝试使用不同的控制器和不同的项目,并且都一样,主页加载正常,但是我无法访问任何控制器

this is how i have configured Nginx 这就是我配置Nginx的方式

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /var/www/qstart/public;
index index.php index.htm;

server_name test-php;

location / {        
    try_files $uri $uri/ =404;      
}


#error_page 404 /404.php;

# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
#   root /usr/share/nginx/html;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    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, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny all;
}
}

Assuming that your framework entry point is /index.php , you need to route most URIs through that script. 假设您的框架入口点是/index.php ,则需要通过该脚本路由大多数URI。 The usual technique is to make it the default action (rather than the 404 return code that you have currently implemented). 通常的技术是使其成为默认操作(而不是当前已实现的404返回代码)。

Try changing the default location block to: 尝试将默认位置阻止更改为:

location / {
    try_files $uri $uri/ /index.php;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM