在apache上部署django 程式

2021-06-12 16:35:12 字數 2558 閱讀 1649

2011-09-21 15:56:38

|  分類:

python & django

|  標籤:

apache |

字型大小訂閱

1.apache和mod_python

(1)安裝apache

1).解壓縮

2).進入~/apache目錄,執行

sudo ./configure --prefix=/usr/server/apache2 --enable-module=so

sudo make

(2)安裝mod_python

1).解壓縮檔案

2).安裝python的開原始檔

sudo apt-get install python-dev

需修改mod_python-3.3.1/src/connobject.c中   

!(b == apr_brigade_sentinel(b)   為   !(b == apr_brigade_sentinel(bb) 

4)、編譯mod_python

cd mod_python-3.3.1

./configure --with-apxs=/usr/server/apache2/bin/apxs --with-python=/usr/bin/python

5).執行

sudo make 

&sudo make install

成功後/usr/server/apache2/modules目錄下應該會出現mod_python.so  sudo make install

(3)在apache中載入mod_python模組

1)、修改apache配置檔案/server/apache2/conf/httpd.conf

首先賦許可權sudo chmod 7 httpd.conf

2).增加裝載mod_python.so的配置行:

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

設定maxrequestsperchild 1,這樣可以在開發階段不用重啟apache進行測試

3.配置根目錄

"/">

#設定http://localhost:8010/  

sethandler python-program

pythonhandler django.core.handlers.modpython

setenv django_settings_module myblog.settings      #配置專案的setttings

pythondebug on

pythonpath "['/home/zhulp/workspaces'] + sys.path"   #配置專案的工作路徑

(5)修改檔案根目錄之後,你就可以將你的網頁存放在新設的目錄下了

在httpd.conf中

documentroot "/home/zhulp/workspaces"

(6)在同乙個 apache 的例項中執行多個 django 程式

127.0.0.1:8010

>

servername 127.0.0.1:8010

"/myblog"

>

sethandler python-program

pythonhandler django.core.handlers.modpython

setenv django_settings_module myblog.settings

pythondebug on

pythonpath "['/home/zhulp/workspaces'] + sys.path"

pythoninterpreter myblog

"/ad"

>

sethandler python-program

pythonhandler django.core.handlers.modpython

setenv django_settings_module myproject2.settings

pythondebug on

pythonpath "['/home/zhulp/workspaces'] + sys.path"

pythoninterpreter myproject2

"/media/"

>

#將站點的特定部分關閉mod_python

# 以.jpg .gif .png 結尾的url遮蔽掉

sethandler none

用mod wsgi在Apache上部署Django

1.安裝和配置apache 2.安裝mod wsgi 1 解壓縮 sudo tar xvf mod wsgi 3.4.tar.gz 2 配置mod wsgi cd mod wsgi 3.4 configure enable shared with apxs usr server apache2 bi...

在Apache上部署Django專案,初步

文中所提及的64位安裝包如python,mod wsgi等都是從 1 機子不能安裝兩個不同版本的python,本人一開始安裝了64位以及32位兩個版本的python,導致的結果就是執行django admin.py的指令的時候沒法找到相應的python執行環境,故解除安裝了32位版本的python。...

Apache上部署PHP環境

如果你的vc環境沒有安裝 或者版本不對 的話則會彈出如下錯誤 接下來配置apache的httpd.conf檔案,使用notepad開啟進行編輯 查詢 dynamic shared object dso support 的部分,並在最後追加 php解壓縮後安裝後的php7apache2 4.dll檔案...