gpt4 book ai didi

php - 在 zend framwork - Nginx - ubuntu 14.04 中使用 Controller 时出现 404

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:26:04 25 4
gpt4 key购买 nike

我正在使用 ubuntu 14.04 并安装了 Nginx、php5 和 Zend 框架 1.12,我需要将这三个用于我正在工作的项目。当我尝试访问索引 (localhost) 时,它会立即加载,但是当我尝试访问像 localhost/Guestbook 这样的 Controller 时(来自他们页面上的指南),我收到 404 错误。我试过使用不同的 Controller 和不同的项目,结果都是一样的,主页加载正常,但我无法访问任何 Controller

这就是我配置 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;
}
}

最佳答案

假设您的框架入口点是 /index.php,您需要通过该脚本路由大多数 URI。通常的技术是使其成为默认操作(而不是您当前已实现的 404 返回代码)。

尝试将默认位置 block 更改为:

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

关于php - 在 zend framwork - Nginx - ubuntu 14.04 中使用 Controller 时出现 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34901391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com