Python 如何在apache Centos 7上设置django项目
我已经在Centos7上创建了一个django项目,现在我正试图让它在ApacheWeb服务器上工作。但在apache错误日志中,我看到以下错误:Python 如何在apache Centos 7上设置django项目,python,django,apache,mod-wsgi,Python,Django,Apache,Mod Wsgi,我已经在Centos7上创建了一个django项目,现在我正试图让它在ApacheWeb服务器上工作。但在apache错误日志中,我看到以下错误: [Mon Apr 23 07:01:02.930780 2018] [:error] mod_wsgi (pid=26121): Target WSGI script '/he/django/myshop/myshop/wsgi.py' cannot be loaded as Python module. [Mon Apr 23 07:01:02.9
[Mon Apr 23 07:01:02.930780 2018] [:error] mod_wsgi (pid=26121): Target WSGI script '/he/django/myshop/myshop/wsgi.py' cannot be loaded as Python module.
[Mon Apr 23 07:01:02.930821 2018] [:error] mod_wsgi (pid=26121): Exception occurred processing WSGI script '/he/django/myshop/myshop/wsgi.py'.
[Mon Apr 23 07:01:02.930842 2018] [:error] Traceback (most recent call last):
[Mon Apr 23 07:01:02.930864 2018] [:error] File "/he/django/myshop/myshop/wsgi.py", line 28, in <module>
[Mon Apr 23 07:01:02.930922 2018] [:error] from django.core.wsgi import get_wsgi_application
[Mon Apr 23 07:01:02.930947 2018] [:error] ImportError: No module named django.core.wsgi
我的/etc/httpd/conf.d/htmltest.psina.com.conf
如下所示:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myshop.settings")
application = get_wsgi_application()
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName 185.201.8.84
ServerAlias www.example.com
DocumentRoot /he/sites/htmltest.psina.com/htdocs/
LogLevel warn
ErrorLog /var/log/httpd/htmltest.psina.com-error.log
CustomLog /var/log/httpd/htmltest.psina.com-access.log combined
WSGIScriptAlias / /he/django/myshop/myshop/wsgi.py
</VirtualHost>
WSGIPythonPath /he/django/myshop
<Directory "/he/sites/htmltest.psina.com/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/he/django/myshop/myshop">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
服务器管理员webmaster@example.com
服务器名185.201.8.84
ServerAlias www.example.com
DocumentRoot/he/sites/htmltest.psina.com/htdocs/
日志级别警告
ErrorLog/var/log/httpd/htmltest.psina.com-error.log
CustomLog/var/log/httpd/htmltest.psina.com-access.log组合
WSGIScriptAlias//he/django/myshop/myshop/wsgi.py
WSGIPythonPath/he/django/myshop
选项索引跟随符号链接
不允许超限
要求所有授权
要求所有授权
首先,我为简单的html页面创建了.conf文件,以检查apache是否工作正常(这就是为什么我的配置中有/he/sites/htmltest.psina.com/htdocs/
。我想我在不同的python版本中遇到了问题,因为我已经为python3.4安装了django,但我不确定这是否是错误的主要原因。您好,上面的错误需要“python35u-mod_wsgi”
您可以从此链接手动安装吗您需要安装apache软件包“mod-wsgi-py3”我尝试过这样做,但遇到了此错误-没有软件包mod-wsgi-py3可用。yum install python35u-mod_wsgiame-没有软件包python35u-mod_wsgi可用。您可以使用“yum search”吗