How to use Django with Apache and mod_wsgi
2011-08-10 21:53
459 查看
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里,然后
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:
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:
相关文章推荐
- IntegrationWithDjango - modwsgi - How to use Django with mod_wsgi. - Python WSGI adapter module for Apache. - Google Project Hosting
- How to use Django with Apache and mod_python
- How to use django with mod_wsgi ¶
- How to use re-write module of Apache web server 2.2.3 on FC6 with new or refurbi
- How to setup Apache + Python + Django + mod_wsgi
- How to use Django with uWSGI
- How to use Django with FastCGI, SCGI, or AJP¶
- Deploying Django with Apache and mod_wsgi Based on Red Hat Enterprise Linux Server
- RESTful WCF Services with No svc file and No config and How to use Service Route
- How to find the correct version of JDeveloper to use with eBusiness Suite 11i or Release 12.x
- OA Framework - How to Find the Correct Version of JDeveloper to Use with E-Business Suite 11i or Release 12.x (Doc ID 416708.1)
- How to configure OpenFiler v2.3 iSCSI Storage for use with VMware ESX.
- How to use bitBucket with EGit in Eclipse,如何在Eclipse中使用bitbucket远程仓库
- How to create aligned partitions in Linux for use with NetApp LUNs, VMDKs, VHDs and other virtual di
- 【hive】How-to: Use a SerDe in Apache Hive
- 基于How To Tango With Django 1.9的重新实践(13)——Template Tags
- How to POST a django form with AJAX & jQuery
- [MSDN]How to use the computer keyboard with Windows Phone Emulator
- How to use Apache Commons CLI
- How to create your own home SVN repository with Xampp/Apache