Amazon Elastic Beanstalk:错误:[Errno 13] 权限被拒绝
Posted
技术标签:
【中文标题】Amazon Elastic Beanstalk:错误:[Errno 13] 权限被拒绝【英文标题】:Amazon Elastic Bean Stalk: error: [Errno 13] Permission denied 【发布时间】:2015-05-10 05:02:07 【问题描述】:我正在 Elastic Bean Stalk 上构建一个烧瓶应用程序。部署后我收到 500 内部服务器错误。当我查看日志时,发现有错误。
Traceback (most recent call last):
File "/opt/python/current/app/application.py", line 32, in <module>
application.run(debug=True, port=server_port, host='0.0.0.0')
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 739, in run
run_simple(host, port, self, **options)
File "/opt/python/run/venv/lib/python2.7/site-packages/werkzeug/serving.py", line 617, in run_simple
test_socket.bind((hostname, port))
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 13] Permission denied
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
mod_wsgi (pid=6577): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
mod_wsgi (pid=6577): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
application.py文件如下
from flask import Flask
application = Flask(__name__)
application.debug = True
# Application routes defined here
@application.route('/index')
def index():
return "Hello World!"
# Run the application
application.run(debug=True, host='0.0.0.0')
我尝试了很多。我不明白发生了什么。在阅读了其他***问题后,我发现这是由于没有root权限引起的。我将如何在弹性豆茎中以 root 权限运行我的 WSGI 脚本。
【问题讨论】:
【参考方案1】:用途:
# Run the application
if __name__ == '__main__':
application.run(debug=True, host='0.0.0.0')
在 mod_wsgi 下运行时不应执行 application.run()
调用。仅在从命令行运行该脚本时才适用。 'if' 语句将确保它不会在 mod_wsgi 下被调用。
【讨论】:
以上是关于Amazon Elastic Beanstalk:错误:[Errno 13] 权限被拒绝的主要内容,如果未能解决你的问题,请参考以下文章
在 Amazon Elastic Beanstalk 上安装 Anaconda
Amazon Elastic Beanstalk 如何采用自定义 python 命令?
如何卸载 Amazon Elastic Beanstalk 命令行界面?