Ubuntu下apache跟Django的整合

2021-08-29 18:59:11 字數 2142 閱讀 1538

2. 編譯mod_python

準備:1)需要apache的開發環境apxs

sudo apt-get install apache2-dev

自動安裝以後的路徑:/usr/bin/apxs2

2)安裝python的開發環境

sudo apt-get install python-dev

3. 配置和安裝mod_python

依次執行下面的命令列,如果沒有出現錯誤基本上就沒問題了

./configure --with-apxs=/usr/bin/apxs2

./configure --with-python=/usr/bin/python2.5

./configure --with-mutex-dir=/var/lock/apache2/mod_python

./configure --with-max-locks=32

接下來編譯

$make

$sudo make install

now don't forget to edit your main config and add

loadmodule python_module /usr/lib/apache2/modules/mod_python.so

and if your configuration uses clearmodulelist, then also

addmodule mod_python.c

記住把loadmodule python_module /usr/lib/apache2/modules/mod_python.so加到apache的配置檔案中。

4. 配置apache

loadmodule python_module /usr/lib/apache2/modules/mod_python.so

pythonoption mod_python.mutex_directory "/var/lock/apache2/"

pythonoption mod_python.mutex_locks 8

5. 配置站點

serveradmin [email protected]

servername www.newtest.com

documentroot /home/dooluu/share/newtest

options indexes followsymlinks multiviews

allowoverride none

order allow,deny

allow from all

alias /images/ "/home/dooluu/share/newtest/images/"

options indexes multiviews followsymlinks

allowoverride none

order deny,allow

allow from all

#control images

order allow,deny

allow from all

#除了都**到django,pythonpath指定站點的根目錄,這裡站點在/home/dooluu/share/newtest下,即diango-admin.py建立的工程,那麼在pythonpath指定為/home/dooluu/share

sethandler python-program

pythonpath "['/home/dooluu/share'] + sys.path"

pythonhandler django.core.handlers.modpython

setenv django_settings_module newtest.settings

pythonautoreload on

pythondebug on

errorlog /var/log/apache2/newtest.log

# possible values include: debug, info, notice, warn, error, crit,

# alert, emerg.

loglevel warn

customlog /var/log/apache2/newtest.log combined

6. 啟動django

訪問:參考:

Ubuntu下Apache中部署Django

環境 ubuntu12.04 server apache2 django1.6 python2.7 mod wsgi 1.安裝apache2 sudo apt get install apache2 2.安裝mod wsgi.so 2.x python sudo apt get install li...

ubuntu下安裝mentohost的deb包

1.我的ubuntu直接雙擊mentohost x x.deb包時預設用歸檔管理器開啟。於是 採用命令安裝 進入 deb所在的目錄 用如下命令 sudo dpkg i packet.deb 2.安裝完成之後 終端 執行 sudo mentohost 3.第一次 需要 配置 mentohost的配置檔...

Ubuntu系統下配置Apache虛擬主機

本文已在本人部落格首發 此教程適合apt get install apache2安裝的apache 進入配置檔案目錄 cd etc apache2 配置檔案說明 apache2.conf apache總的配置檔案 ports.conf 埠配置檔案 sites enables 000 default....