繁体   English   中英

如何为django wsgi配置apache2?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM