在ubuntu上为django应用程序设置apache服务器。卡在mod_wsgi配置上。以下是sites-available / 000-default.conf中的内容:
WSGIPythonPath /var/www/html
WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
缺少什么?服务器不会返回默认的django管理页面:8080
答案 0 :(得分:0)
如果您想在端口8080上使用东西,则必须在配置而不是80上指定它。 / var / www / html上有什么?你应该用你的Django项目路径替换它,比如/ var / django / project_name /或者/ var / django / project_name / project_name(如果你有重复的话)
以下是我成功配置wsgi.py的方法:
import os,sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('/var/django/project_name/project_name')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mideastinfo.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
在Apache配置上的VirtualHost指令中,您必须具有:
WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py
示例:
<VirtualHost *:8080>
ErrorLog /home/user/logs/error.log
...
WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py
...
</VirtualHost>