![](/img/trans.png)
[英]How to run Django app with Apache2, mod_wsgi and Anaconda?
[英]How to configure apache2 for django wsgi?
我試圖使用apache2運行django應用程序,但失敗了。 它給了我500個內部服務器錯誤The server encountered an internal error or misconfiguration and was unable to complete your request.
首先,我在主目錄中創建了一個firstweb.wsgi文件。 並把這個代碼
import os
import sys
sys.path = ['/var/www/firstweb'] + sys.path
os.environ['DJANGO_SETTINGS_MODELE'] = 'firstweb.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
在我的/etc/apache2/sites-available
我創建了一個名為firstweb.conf的文件。
<VirtualHost *:80>
WSGIScriptAlias / /home/nihan/firstweb.wsgi
ServerName firstweb.com
Alias /static /var/www/firstweb/static
<Directory /var/www/firstweb/ >
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
在我的/var/www/
我通過鍵入創建了一個django項目
sudo django-admin.py startproject firstweb
這是我第一次嘗試apache,mod_wsgi和Django
請幫助我了解我錯過了
通常運行Apache的用戶無權訪問主目錄中的內容。 無法確認這種情況,因為您沒有提供Apache錯誤日志中的錯誤消息,僅提供了瀏覽器中顯示的錯誤消息。 建議您觀看:
該演講涵蓋了類似的常見錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.