我試圖在Django + mod_wsgi和apache的web瀏覽器中加載一個網站。我的問題與This Question Here完全相同,但在我的情況下找到的解決方案不起作用。Django + mod_wsgi致命Python錯誤:Py_Initialize:沒有名爲Encodings的模塊
這裏是我的httpd-vhosts.conf設置:
WSGIDaemonProcess binshellpress.com python-home=/usr/local/docs/binshellpress-production/virtpy/ python-path=/usr/local/docs/binshellpress-production/virtpy/lib/python3.6/
WSGIProcessGroup binshellpress.com
WSGIApplicationGroup %{GLOBAL}
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/usr/local/docs/binshellpress-production/root"
ServerName binshellpress.com
ServerAlias www.binshellpress.com
ErrorLog "/var/log/httpd/bsp-error_log"
CustomLog "/var/log/httpd/bsp-access_log" common
Alias /robots.txt /usr/local/docs/binshellpress-production/static/robots.txt
Alias /favicon.ico /usr/local/docs/binshellpress-production/static/favicon.ico
Alias /media/ /usr/local/docs/binshellpress-production/media
Alias /static/ /usr/local/docs/binshellpress-production/static
<Directory /usr/local/docs/binshellpress-production/static>
Require all granted
</Directory>
<Directory /usr/local/docs/binshellpress-production/media>
Require all granted
</Directory>
WSGIScriptAlias//usr/local/docs/binshellpress-production/binshellpress/wsgi.py process-group=binshellpress.com
<Directory /usr/local/docs/binshellpress-production/binshellpress>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</Virtualhost>
我有一個虛擬的環境中/usr/local/docs/binshellpress-production/virtpy
成立。我已經重建了mod_wsgi來明確地使用那個虛擬環境。我已執行權限修改,如This Question
的答案中所述。無變化。
我很絕望。我一直在上下尋找。我無法弄清楚該怎麼做。請幫幫我。我求求你。
謝謝,任何事情,謝謝,只是請,幫助我,謝謝。
在服務器上,正如用戶Apache運行的那樣,您是否嘗試過激活virtualenv並執行'python manage.py runserver'?這往往會暴露潛在的問題。用系統範圍的Python安裝編譯mod_wsgi總是最好的,而不是virtualenv中的一個,但它必須是您構建virtualenv所用的相同版本。 – FlipperPA
即使使用虛擬環境,也不一定要針對系統Python編譯mod_wsgi。事實上,當你在虛擬環境中運行「pip install mod_wsgi」時,它別無選擇。 –