我有一个奇怪的 symfony 问题。我正在尝试使用 Symfony 3.4 和 nginx。
我按照“创建您的第一页”教程进行操作,但是当我使用 URL /symfony/Symfony/web/app_dev.php/lucky/number时,只有 **/symfony/Symfony/web/app_dev.php** 页面正在工作,IT展示
“nginx 错误!未找到您要查找的页面。”
幸运控制器.php
<?php
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class LuckyController extends Controller
{
/**
* @Route("/lucky/number", name="luckyNumber")
*/
public function numberAction()
{
$number = random_int(0, 100);
return $this->render('lucky/number.html.twig', [
'number' => $number,
]);
}
}
配置文件
server {
listen 80;
server_name domain.tld www.domain.tld;
root /usr/share/nginx/html/;
location / {
try_files $uri /index.php$is_args$args;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
路由.yml
app:
resource: '@AppBundle/Controller/'
type: annotation
杨魅力