[Linux]Django + lighty 安裝
紀錄一下安裝流程
(0) Python 2.6
flup (python library for fastCGI)
(1) Lighttpd
# apt-get install lighttpd
(2) Django
# wget xxx
# python setup.py install
(3) 修改lighttpd.config
# vi /etc/lighttpd/lighttpd.conf
(a)增加 mod_fastcgi (順序要在mod_access, mod_rewrite之後, mod_accesslog之前)
(b)修改預設路徑 server.document-root "/home/xxx"
(c)指定fastcgi.server的處理方式
(d)撰寫 mysite.fcgi
(e) create project and execute
# django-admin.py startproject mysite
# cd mysite
# python manage.py runserver 10.0.2.5:8899
* 若server ip會改變, 可以使用 0.0.0.0:8899
參考: 連結一、連結二
(0) Python 2.6
flup (python library for fastCGI)
(1) Lighttpd
# apt-get install lighttpd
(2) Django
# wget xxx
# python setup.py install
(3) 修改lighttpd.config
# vi /etc/lighttpd/lighttpd.conf
(a)增加 mod_fastcgi (順序要在mod_access, mod_rewrite之後, mod_accesslog之前)
(b)修改預設路徑 server.document-root "/home/xxx"
(c)指定fastcgi.server的處理方式
fastcgi.server = (
"/mysite.fcgi" => (
"main" => (
"socket" => "/home/xxx/mysite.sock",
"check-local" => "disable",
)
),
(d)撰寫 mysite.fcgi
#!/usr/bin/python
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home/user/python")
# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
(e) create project and execute
# django-admin.py startproject mysite
# cd mysite
# python manage.py runserver 10.0.2.5:8899
* 若server ip會改變, 可以使用 0.0.0.0:8899
參考: 連結一、連結二
Comments
Post a Comment