python - 如何使用 AWS ElasticBeanstalk 更改 wsgi.conf?
问题描述
我的问题是我无法保存文件,因为 elasticbeanstalk 工作人员的权限被拒绝。WSGI 组没有写权限。所以我想给wsgi进程写权限。
解决方案是更改 wsgi.conf。
.ebextensions/01_change_wsgi.config
container_commands:
04_wsgireplace:
command: "cp .ebextensions/wsgi.conf ../wsgi.conf"
我制作了 .ebextensions/wsgi.conf。这有 umask 选项。
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On
<VirtualHost *:80>
Alias /static/ /opt/python/current/app/static/
<Directory /opt/python/current/app/static/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /opt/python/current/app/application.py
<Directory /opt/python/current/app/>
Require all granted
</Directory>
WSGIDaemonProcess my-wsgi processes=1 umask=0002 threads=15 display-name=%{GROUP} \
python-home=/opt/python/run/venv/ \
python-path=/opt/python/current/app user=my-wsgi group=my-wsgi \
home=/opt/python/current/app
WSGIProcessGroup my-wsgi
</VirtualHost>
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
部署后,/var/log/eb-activity.log 中有错误消息。
[2020-04-10T10:53:36.631Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1] : Starting activity...
[2020-04-10T10:53:36.631Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1/AppDeployEnactHook] : Starting activity...
[2020-04-10T10:53:36.631Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1/AppDeployEnactHook/01flip.py] : Starting activity...
[2020-04-10T10:53:44.661Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1/AppDeployEnactHook/01flip.py] : Activity execution failed, because: httpd: stopped
httpd: ERROR (abnormal termination)
apache failed to start... killing all existing httpd processes and trying again
httpd: no process found
Semaphores owned by apache:
Deleting apache semaphores:
httpd: ERROR (already started)
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/enact/01flip.py", line 42, in <module>
main()
File "/opt/elasticbeanstalk/hooks/appdeploy/enact/01flip.py", line 36, in main
config.restart_apache()
File "/opt/elasticbeanstalk/hooks/config.py", line 251, in restart_apache
apache_cmd('restart', should_be_running=True)
File "/opt/elasticbeanstalk/hooks/config.py", line 258, in apache_cmd
ensure_apache_is_running()
File "/opt/elasticbeanstalk/hooks/config.py", line 280, in ensure_apache_is_running
raise PythonHooksError("Apache is not running, but it's supposed to be.")
config.PythonHooksError: Apache is not running, but it's supposed to be. (ElasticBeanstalk::ExternalInvocationError)
caused by: httpd: stopped
httpd: ERROR (abnormal termination)
apache failed to start... killing all existing httpd processes and trying again
httpd: no process found
Semaphores owned by apache:
Deleting apache semaphores:
httpd: ERROR (already started)
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/enact/01flip.py", line 42, in <module>
main()
File "/opt/elasticbeanstalk/hooks/appdeploy/enact/01flip.py", line 36, in main
config.restart_apache()
File "/opt/elasticbeanstalk/hooks/config.py", line 251, in restart_apache
apache_cmd('restart', should_be_running=True)
File "/opt/elasticbeanstalk/hooks/config.py", line 258, in apache_cmd
ensure_apache_is_running()
File "/opt/elasticbeanstalk/hooks/config.py", line 280, in ensure_apache_is_running
raise PythonHooksError("Apache is not running, but it's supposed to be.")
config.PythonHooksError: Apache is not running, but it's supposed to be. (Executor::NonZeroExitStatus)
[2020-04-10T10:53:44.662Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1/AppDeployEnactHook/01flip.py] : Activity failed.
[2020-04-10T10:53:44.662Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1/AppDeployEnactHook] : Activity failed.
[2020-04-10T10:53:44.662Z] INFO [20557] - [Application update app-0955-200410_195235@43/AppDeployStage1] : Activity failed.
[2020-04-10T10:53:44.662Z] INFO [20557] - [Application update app-0955-200410_195235@43] : Completed activity. Result:
我应该怎么办?
解决方案
推荐阅读
- cruisecontrol.net - 防止在使用 cc.net 进行其他构建时强制构建
- python - 将元组条目解析为字符串
- powershell - Powershell 向上取整函数
- javascript - 防止keydown事件javascript
- javascript - 如何使用 jquery 获取 div 内的所有内容,包括脚本和样式标签?
- node.js - 如何删除多个同名文件?
- android - 如何更改firebase数据库中的密钥?
- java - 使用 JavaParser 使用 getExtendedType 查找继承
- ios - 来自自定义 UIViewController 和 CocoaPods 库的多重继承
- vba - 比较 2 个工作簿