更改根文件 aws nginx 服务器

Change root file aws nginx server

我已经坚持了一段时间。我们有一个 Symfony 2.8 项目,我想将它部署到云端。我已经正确地创建了 ElasticBeanstalk 环境并且它可以工作!但我仍然需要访问 http://domain/app.php 才能使其正常工作。我设法从 URL 中删除了 web/changing documentDirectory 部分,但 app.php 仍然存在。

我还尝试了一个新的品牌项目: https://docs.aws.amazon.com/es_es/elasticbeanstalk/latest/dg/php-symfony-tutorial.html 但是,当我将其更改为 public/ 时,发生同样的情况,我需要在 URL

中使用 index.php

我修改了 NGINX conf 如下: https://community.bitnami.com/t/how-to-change-default-root/65639/9 https://symfony.com/doc/current/setup/web_server_configuration.html

这是我添加到/etc/nginx/nginx的内容。conf.default

  location / {
    try_files $uri $uri/ /app.php$is_args$args;
}

 location ~ \.php$ {
    try_files $uri $uri/ =404;
    fastcgi_pass unix:/var/run/php-fpm/www.sock;
    fastcgi_index app.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

我已经使用

重启了 nginx 服务
sudo service nginx restart

但还是一样。

我也试过将 app.php 重命名为 index.php 以防万一。但是我需要将 /index.php 添加到 URL 然后。

有什么想法吗?

有些事情您可以尝试。

https://symfony.com/doc/2.8/setup/web_server_configuration.html#nginx

在这里您可以找到您项目的配置。在那里你可以看到该位置被重写为 app.php.

location ~ ^/(app_dev|config)\.php(/|$) {

所以我建议进行配置并进行测试。

使用 index nginx 指令使 app.php 成为 http://domain/ 请求的默认处理程序:

server {
    ...
    index    app.php;
    # your locations here
}