How to use Django with Apache and mod_wsgi

edit httpd.conf

WSGIScriptAlias / /home/liuke/www/django/hello/apache/django.wsgi

add file

django.wsgi

import os
import sys

path = '/home/liuke/www/django/hello'
if path not in sys.path:
    sys.path.append(path)


#os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

官方网站上说是os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

这样会出错试了改为settings就可以

or
把path = '/home/liuke/www/django/hello'

改为path = '/home/liuke/www/django'

应该也可以吧

edit setting.py 开头加入

import sys
sys.path.append('/home/liuke/www/django/hello')
sys.path.append('/home/liuke/www/django/')

还有里面的path要是绝对path

sqlite3的数据文件为出现为readonly 的error,

要把数据文件单独放在一个dir里,然后

chown www-data. .

Aha, just stumbled across an article explaining this. Also Django have info on their NewbieMistakes page.

The solution is to make sure the directory containing the database file also has write access allowed to the process.

In my case, running this command fixed the problem:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值