我正在使用MAMP + nginx + phalcon建立一个网站。我已经设置了一切,phalcon正在工作,但它只看到IndexController和indexAction。如果我添加更多控制器并尝试导航到它们,我会得到404错误。此外,如果我添加另一个动作到IndexController,我不能得到它,我再次得到404错误。这是我的nginx配置文件:
server {
listen 7888 default_server;
root "/dev/testing/public";
location / {
index index.html index.php;
}
location ~ '.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我的index.php与phalcon文档中给出的索引相同。任何建议/见解将不胜感激。
你的nginx配置文件应该指向你的引导文件(通常是你的index.php
在你的公共文件夹)传递_url
参数包含原始路径请求。
这就是Phalcon路由器开箱即用的原理。
正确的配置块可能因项目的文件结构而异。所以你需要阅读Phalcon的Nginx安装说明,看看哪些配置是你需要的。
尝试查看这里的phalcon nginx文档https://docs.phalconphp.com/en/latest/reference/nginx.html,我能够使用这种配置是因为我们传递了_url param