即使在.ebextensions配置文件中设置了权限,ElasticBeanstalk上的Laravel仍会出现``拒绝日志文件权限''错误 [英] Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file

查看:128
本文介绍了即使在.ebextensions配置文件中设置了权限,ElasticBeanstalk上的Laravel仍会出现``拒绝日志文件权限''错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的Laravel应用程序部署到ElasticBeanstalk环境.但是我在laravel.log文件权限方面遇到问题.

I am deploying my Laravel application to the ElasticBeanstalk environment. But I am having issue with laravel.log file permissions.

我使用"eb deploy"部署了我的应用程序,命令.部署后,我将访问我的应用程序.但这会引发以下错误.

I deployed my application using "eb deploy" command. After I deployed, I access my application. But it is throwing the following error.

The stream or file "/var/app/current/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

要解决此问题,我将ssh放入服务器并运行以下命令.

To solve the issue, I ssh into the server and run the following command.

sudo -u root chmod 777 -R /var/app/current/storage/logs

问题已解决.现在我的应用程序正在运行.但是我再次运行我的应用程序运行".命令.部署后,问题再次弹出.以一致的方式解决问题.我试图按如下所示在.ebextensions配置文件中运行命令.

The problem is solved. Now my application is working. But I deploy my application again running "be deploy" command. After the deployment, the issue popped up again. To solve the issue in a consistent way. I tried to run the command in the .ebextensions config file as follow.

container_commands:
  01-migrations:
    command: "php artisan migrate --force"
  02-log-storage-permissions:
    command: "sudo -u root chmod -R 777 /var/app/current/storage/logs/"

我可以部署我的应用程序.但是问题仍然存在.似乎该命令不起作用.我的配置有什么问题,我该如何解决?

I could deploy my application. But the issue still persists. It seems like the command is not working. What is wrong with my configuration and how can I fix it?

推荐答案

我相信这是因为container_commands在您的应用程序位于暂存文件夹中时运行.因此,运行02-log-storage-permissions后,无论如何/var/app/current都将被登台文件夹替换.因此,您的chmod不会持久.

I believe that this is because container_commands run when your application is in the staging folder. Thus, after you run 02-log-storage-permissions, your /var/app/current will be replaced anyway with the staging folder. So your chmod wont persist.

要解决此问题,您可以尝试以下两个选项之一:

To rectify the issue, you can try one of the two options:

  1. 使用

  02-log-storage-permissions:
    command: "sudo -u chmod -R 777 ./storage/logs/"

更改登台文件夹中的日志.

to change the logs in staging folder.

  1. 使用 postdeploy 钩子来运行您的脚本:
  1. use postdeploy hook to run your script:

之后,Elastic Beanstalk平台引擎部署应用程序和代理服务器.

after the Elastic Beanstalk platform engine deploys the application and proxy server.

这篇关于即使在.ebextensions配置文件中设置了权限,ElasticBeanstalk上的Laravel仍会出现``拒绝日志文件权限''错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆