更改根文件 aws nginx 服务器

我已经坚持了一段时间。我们有一个 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。


任何想法?


米脂
浏览 113回答 2
2回答

牛魔王的故事

使用indexnginx 指令创建请求app.php的默认处理程序http://domain/:server {    ...    index    app.php;    # your locations here}

皈依舞

您可以尝试一些事情。https://symfony.com/doc/2.8/setup/web_server_configuration.html#nginx在这里您可以找到项目的配置。在那里你可以看到该位置被重写为app.php.location ~ ^/(app_dev|config)\.php(/|$) {所以我建议进行配置并进行测试。
打开App,查看更多内容
随时随地看视频慕课网APP