2017-09-24 130 views
-1

我想使用apache和mod_wsgi打開Django服務器。 我寫下如下django apache wsgi問題

sudo apt-get install apache2 
sudo apt-get install libapache2-mod-wsgi 

,並創建Django項目和應用程序,並添加我的機器人在setting.py 和創建虛擬環境,並使用 和seoultech/wsgi.py/Django的= mydirctory添加下面的代碼/ seoultech =項目/ BOT =應用程序/

import os, sys 

sys.path.append('/home/django') 
sys.path.append('/home/django/venv/lib/python2.7/site-packages') 

from django.core.wsgi import get_wsgi_application 

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

application = get_wsgi_application() 

和CD /etc/apache2/site-available/000-default.conf 附加代碼

WSGIDaemonProcess seoultech python-path=/home/django/seoultech=home/django 
/venv/lib/python2.7/site-packages 
<VirtualHost *:80> 

    ServerAdmin [email protected] 
    WSGIScriptAlias//home/django/seoultech/wsgi.py 


<Directory /home/django/seoultech> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
</Directory 
</VirtualHost> 

但須藤的apachectl-K開始我得到錯誤

'AH00526: Syntax error on line 1 of /etc/apache2/sites-enabled 
/000default.conf:Invalid command 'WSGIDaemonProcess', perhaps misspelled 
or defined by a module not included in the server configuration Action '-k 
start' failed.The Apache error log may have more information.' 

IM期待幫助

+0

正確加載/啓用mod_wsgi後,由於錯誤提示存在問題,因此缺少WSGIProcessGroup指令,並且沒有正確配置Python虛擬環境。見http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html –

回答

0

廣場WSGIDaemonProcess虛擬主機內擺脫這種錯誤的。

<VirtualHost *:80> 

    ServerAdmin [email protected] 

    WSGIDaemonProcess seoultech python-path=/home/django/seoultech=home/django 
/venv/lib/python2.7/site-packages 
    WSGIScriptAlias//home/django/seoultech/wsgi.py 


<Directory /home/django/seoultech> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
</Directory 
</VirtualHost> 
+0

我得到同樣的錯誤...幫我 –

+0

sudo a2enmod wsgi? –

+0

錯誤:模塊wsgi不存在! –