尝试在apache上运行django时导入错误

时间:2017-02-01 09:07:38

标签: django apache mod-wsgi django-wsgi

我正在尝试在django服务器上运行我的apache项目。我没有在django上运行virtualenv项目。我在views.py中有以下代码,其中 导入错误 没有名为startInsight的模块 每次。如果我与python manage.py runserver 0.0.0.0:80一起运行,那就完全一样了。

views.py中的错误点:

sys.path.insert(0,"/Insight/scripts")
import startInsight

以下是我的配置: -

/etc/apache2/sites-available/000-default.conf:

 <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /web/mysite
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /web/mysite>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Require all granted
    </Directory>

    Alias /static /web/mysite/mysite/static
    <Directory /web/mysite/mysite/static>
            Require all granted
    </Directory>

    <Directory /web/mysite/mysite>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WSGIDaemonProcess mysite python-path=/usr/bin/python:/web/mysite
    WSGIProcessGroup mysite
    WSGIScriptAlias / /web/mysite/mysite/wsgi.py
</VirtualHost>

/web/mysite/mysite/wsgi.py:

import os
'''
I tried adding these two lines below. Did not make a difference.
import sys
sys.path.insert(0,"/Insight/scripts")
'''
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

我不确定我做错了什么,需要一些指导。

0 个答案:

没有答案