当我尝试访问Laminas应用程序的基本URL以外的任何地方时,Nginx会在我的应用程序中给我404错误;从我的日志记录中看来,它似乎试图将路由作为文件/目录进行服务。
我使用 Laminas MVC框架的README 提供的信息来配置我的虚拟主机;看起来应该将路由传递到public目录的index.php,但出于某种原因它未能这样做。
这是我的配置(/etc/nginx/sites-available/domain.com):
我使用 Laminas MVC框架的README 提供的信息来配置我的虚拟主机;看起来应该将路由传递到public目录的index.php,但出于某种原因它未能这样做。
这是我的配置(/etc/nginx/sites-available/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;
}
}
fastcgi_pass
似乎是错误的。此外,Laminas 使用一个public
文件夹,你的fastcgi_param
中也包含了吗? - Chris Haas/sites/domain.com/
是指向项目公共目录的符号链接。 - Renze