这两个的安装都是直接命令安装,
apt-get install libapache2-mod-wsgi
查看mod_wsgi是否安装成功,找文件/usr/lib/apache2/modules/mod_wsgi.so
编辑/etc/apache2/httpd.conf,加入:
# LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIScriptAlias / "/data/web/test/mysite/apache/django.wsgi"
<Directory "/data/web/mysite">
Order Deny,Allow
Allow from all
</Directory>
#那句不用写,加入以后会提示“已经载入mod_wsgi”
[warn] module wsgi_module is already loaded, skipping
以后还要再配置一次,现在做个测试。主要参照官网。
Alias /robots.txt /usr/local/wsgi/static/robots.txt
Alias /favicon.ico /usr/local/wsgi/static/favicon.ico
AliasMatch ^/([^/]*\.css) /usr/local/wsgi/static/styles/$1
Alias /media/ /usr/local/wsgi/media/
Alias /static/ /usr/local/wsgi/static/
<Directory /usr/local/wsgi/static>
Order deny,allow
Allow from all
</Directory>
<Directory /usr/local/wsgi/media>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /usr/local/wsgi/scripts/django.wsgi
<Directory /usr/local/wsgi/scripts>
Order allow,deny
Allow from all
</Directory>
/data/web/test/mysite/apache/django.wsgi
# -*- coding: utf-8 -*-
import os
import sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
apache的日志文件存放在:/var/log/apache2/目录下。
上一篇: Ubuntu安装mod_python错误
下一篇: Django的comments框架使用
0 Responses so far.