首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >让mod-wsgi运行使用python3编写的应用程序时出现问题

让mod-wsgi运行使用python3编写的应用程序时出现问题
EN

Stack Overflow用户
提问于 2020-06-30 20:58:48
回答 1查看 129关注 0票数 1

我已经花了几个星期来研究这个问题了。我使用这些instructionsthis YouTube video让mod_wsgi工作。

当我使用我所学到的知识将我自己的应用程序放在我的web服务器上时,我遇到了一些问题,但我解决了大部分问题。“拦路虎”是我为Python3.6编写的应用程序,导入导致了错误,因为mod_wsgi试图使用Python2.7来运行它们。进一步的学习使我意识到我需要安装libapache2-mod-wsgi-py3而不是libapache2-mod-wsgi。至少,这是我从here上读到的。

现在,我有一个新的错误:

代码语言:javascript
运行
AI代码解释
复制
ubuntu@ip-172-26-13-175:~$ sudo systemctl start apache2
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

基于此,我尝试:

代码语言:javascript
运行
AI代码解释
复制
ubuntu@ip-172-26-13-175:~$ sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Tue 2020-06-30 18:44:53 UTC; 14s ago
  Process: 6773 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

Jun 30 18:44:53 ip-172-26-13-175 systemd[1]: Starting The Apache HTTP Server...
Jun 30 18:44:53 ip-172-26-13-175 apachectl[6773]: AH00526: Syntax error on line 1 of /etc/apache2/conf-enabled/mod-wsgi.conf:
Jun 30 18:44:53 ip-172-26-13-175 apachectl[6773]: Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Jun 30 18:44:53 ip-172-26-13-175 apachectl[6773]: Action 'start' failed.
Jun 30 18:44:53 ip-172-26-13-175 apachectl[6773]: The Apache error log may have more information.
Jun 30 18:44:53 ip-172-26-13-175 systemd[1]: apache2.service: Control process exited, code=exited status=1
Jun 30 18:44:53 ip-172-26-13-175 systemd[1]: apache2.service: Failed with result 'exit-code'.
Jun 30 18:44:53 ip-172-26-13-175 systemd[1]: Failed to start The Apache HTTP Server.

基于此,我检查:

代码语言:javascript
运行
AI代码解释
复制
ubuntu@ip-172-26-13-175:~$ cat /etc/apache2/conf-enabled/mod-wsgi.conf
WSGIScriptAlias /test_wsgi /var/www/html/wsgi_test_script.py

在此基础上,我检查该别名的目标是否存在并具有有效代码:

代码语言:javascript
运行
AI代码解释
复制
ubuntu@ip-172-26-13-175:~$ cat /var/www/html/wsgi_test_script.py
def application(environ,start_response):
    status = '200 OK'
    html = '<html>\n' \
           '<body>\n' \
           ' Hooray, mod_wsgi is working\n' \
           '</body>\n' \
           '</html>\n'
    response_header = [('Content-type','text/html')]
    start_response(status,response_header)
    return [html]

既然一切都检查过了,我不知道该如何解决这个问题。我甚至不知道下一步该检查什么。显然,如果我不能启动Apache,我的Flask/mod_wsgi应用程序将无法工作。

任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-01 21:11:52

我想通了。

我只是使用以下命令禁用了导致问题的conf:

代码语言:javascript
运行
AI代码解释
复制
sudo a2disconf mod-wsgi.conf

Apache现在完美地启动了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62666052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档