将Symfony应用程序部署到Elastic Beanstalk

问题描述 投票:-2回答:1

我正在尝试将Symfony应用程序部署到Elastic Beanstalk,但似乎URL重写无法正常工作。

使用平台在64位Amazon Linux 2上运行的PHP 7.4]和文档根为/ public

。platform / nginx / conf.d / nginx.conf

server {
  listen        80;
  root /var/app/current/public;
  index index.php;
  location / {
      # try to serve file directly, fallback to index.php
      try_files $uri /index.php$is_args$args;
  }
   location ~ ^/index\.php(/|$) {
    #fastcgi_pass unix:/var/run/php-fpm.sock;
          fastcgi_pass  php-fpm;
          fastcgi_split_path_info ^(.+\.php)(/.*)$;
        #include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
          fastcgi_param DOCUMENT_ROOT $realpath_root;
   }
  access_log    /var/log/nginx/access.log main;
  client_header_timeout 60;
  client_body_timeout   60;
  keepalive_timeout     60;
  gzip                  off;
  gzip_comp_level       4;
  # Include the Elastic Beanstalk generated locations
  #include conf.d/elasticbeanstalk/*.conf;
}

但是服务器找不到domain.com/auth/login的路径(但适用于domain.com/index.php/auth/login。>

----------------------------------------
/var/log/nginx/error.log
----------------------------------------
2020/05/16 17:32:48 [warn] 3709#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:32:48 [warn] 3736#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:32:48 [warn] 3740#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:33:29 [error] 3744#0: *2 open() "/var/www/html/public/auth/login" failed (2: No such file or directory), client: 172.31.42.4, server: , request: "GET /auth/login HTTP/1.1", host: "..."

如果删除fastcgi_params的注释标记(#),则找不到它。

我在/var/log/eb-engine.log中发现了一个有趣的'错误':

2020/05/16 18:21:37.054548 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2020/05/16 18:21:37.064522 [ERROR] nginx: the configuration file /var/proxy/staging/nginx/nginx.conf syntax is ok
nginx: configuration file /var/proxy/staging/nginx/nginx.conf test is successful

我正在尝试将Symfony应用程序部署到Elastic Beanstalk,但似乎URL重写无法正常工作。使用在64位Amazon Linux 2上运行的平台PHP 7.4,文档根目录为/ ...

symfony amazon-elastic-beanstalk
1个回答
0
投票

要在AWS Linux 2上启用URL重写,您必须添加以下文件(来自根目录)。您不需要修改nginx.conf

创建文件:

© www.soinside.com 2019 - 2024. All rights reserved.