简体   繁体   中英

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. 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. 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

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. The usual technique is to make it the default action (rather than the 404 return code that you have currently implemented).

Try changing the default location block to:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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