Php 状态404:ZF3和Nginx
Nginx在我的Laminas应用程序上给了我一个404,当我尝试在基本URL以外的任何地方导航时;从我的日志来看,它似乎试图将路由作为文件/目录提供服务 我使用中的信息来配置我的VH;在我看来,它应该将路由传递到公共目录的Php 状态404:ZF3和Nginx,php,nginx,http-status-code-404,url-routing,zend-framework3,Php,Nginx,Http Status Code 404,Url Routing,Zend Framework3,Nginx在我的Laminas应用程序上给了我一个404,当我尝试在基本URL以外的任何地方导航时;从我的日志来看,它似乎试图将路由作为文件/目录提供服务 我使用中的信息来配置我的VH;在我看来,它应该将路由传递到公共目录的index.php,但由于某种原因,它不是 这是我的配置(/etc/nginx/sites available/domain.com): 试试这个 用于尝试所有php、URI和html文件的位置块(同时保留查询字符串参数) 一个php块,传递给fpm sock 拥有多个f
index.php
,但由于某种原因,它不是
这是我的配置(/etc/nginx/sites available/domain.com
):
试试这个
- 用于尝试所有php、URI和html文件的位置块(同时保留查询字符串参数)
- 一个php块,传递给fpm sock
拥有多个
fastcgi\u通行证似乎是错误的。另外,Laminas使用了一个公共
文件夹,您的fastcgi_param
是否也包含该文件夹?@ChrisHaas/sites/domain.com/
是指向项目公共目录的符号链接。
server {
listen 80 default_server;
listen [::]:80 default_server;
root /sites/domain.com;
index index.php
server_name domain.com;
location / {
index index.php
try_files $uri $uri/ @php;
}
location @php {
# Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME /sites/domain.com/index.php;
include fastcgi_params;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /sites/domain.com;
index index.php
server_name domain.com;
location / {
try_files $uri $uri/ /index.html /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}