弹性beantalk上的wsgi用户权限 [英] wsgi user permissions on elastic beanstalk
问题描述
我正在使用弹性beantalk和django.我的requirements.txt文件中的一个依赖项进行了一些设置,该设置在其最初导入时执行.设置的一部分是检查目录是否存在,否则将创建该目录.我收到权限错误,因为用户(我假设是wsgi)没有创建目录的权限.
I'm using elastic beanstalk and django. One of my dependencies in my requirements.txt file has some setup the it performs when it's initially imported. Part of the setup is to check whether a dir exists else it create it. I'm getting permissions errors because the user ( I assume it's wsgi) does not have the permissions to create the dir.
OSError: [Errno 13] Permission denied: '/home/wsgi/.newspaper_scraper/memoized'
我如何设置权限以允许以将来在我以后创建的实例之间持久的方式创建这些目录?
How can I setup permissions to allow for these dirs to be created in a way that will be persistent across instances I create in the future?
推荐答案
之所以会发生这种情况,是因为uWSGI worker在具有受限权限的用户下运行.您需要首先创建.newspaper_scraper/memoized
目录,并在其上设置正确的权限(允许其他人使用r/w).您可以在部署时执行此操作,方法是在.ebextensions
中创建一个脚本,该脚本在部署后由EB执行.
This is happening because the uWSGI worker is running under a user with limited permissions. You need to create the .newspaper_scraper/memoized
directory first, and set the correct permissions on it (allow others to r/w). You can do this on deployment by making a script in .ebextensions
that EB executes upon deployment.
在.ebextensions/setup_newspaper.config
中创建一个文件,并将以下内容添加到其中:
Create a file in .ebextensions/setup_newspaper.config
and add the following to it:
.ebextensions/setup_newspaper.config
packages:
yum:
libxslt-devel: []
libxml2-devel: []
libjpeg-devel: []
zlib1g-devel: []
libpng12-devel: []
container_commands:
01_setup_newspaper:
command: mkdir -p /home/wsgi/.newspaper_scraper/memoized && chmod 644 /home/wsgi/.newspaper_scraper/memoized
PS:看来newspaper
需要安装一些额外的软件包,所以我也添加了它们.
PS: It looks like newspaper
requires some extra packages to be installed, so I added them too.
在 .ebextensions 上了解更多信息: 查看全文