我正在将我的 Laravel 应用程序部署到 AWS ElasticBeanstalk。我已经部署了它。现在,我正在尝试使用 .platform 文件夹覆盖“/etc/nginx/conf.d/elasticbeanstalk/php.conf”文件。
我在项目的根文件夹中创建了 .platform/etc/nginx/conf.d/elasticbeanstalk/php.conf 文件。然后我把配置内容放进去。
然后我部署我的应用程序,执行“be deploy”命令。但是 Nginx 配置文件没有被覆盖。我的配置有什么问题,我怎样才能让它工作?
我也尝试使用 .ebextensions 创建一个包含以下内容的配置文件。该文件不仅仅是创建的。
files:
/etc/nginx/conf.d/elasticbeanstalk/laravel.conf:
mode: "000755"
owner: root
group: root
content: |
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
最佳答案
nginx
您尝试设置的配置文件用于 亚马逊 Linux 1 (AL1)。
对于 AL2,nginx
应该使用以下方法提供配置文件( aws docs ):
.platform/nginx/conf.d/
或者如果你想覆盖主
nginx
配置文件,使用.platform/nginx/nginx.conf
因此,您可以尝试以下文件
.platform/nginx/conf.d/laravel.conf
内容如下:location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
如果它不起作用,您可以在 /var/log
中检查 nginx 日志。或 nginx config 文件夹以检查文件是否正确放置在 nginx config 文件夹中。Solution I used
我使用了这个并且它起作用了。
.platform/nginx/conf.d/elasticbeanstalk/laravel.conf
关于laravel - AWS Elasticbeanstalk 使用 .platform 覆盖 Nginx 配置不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62901090/