apache python 模塊mod_wsgi的編譯安裝

apache python 模塊mod_wsgi的編譯安裝

WSGI是一個通用的API底層Web服務器之間的映射和Python的Web應用程序的規範。WSGI本身就是Python的PEP 0333。WSGI規範的目的是提供一個共同的機制,舉辦了一系列不同的Web服務器,支持Python編程語言的一個Python的Web應用程序。

下載:

[root@htuidc src]# wget https://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz

[root@htuidc mod_wsgi-3.4]# ./configure --enable-shared

這裏,必須用–enable-shared,生成動態庫,否則會遇到wsgi不能編譯的問題。

如果出現錯誤:config.status: error: cannot find input file: Makefile.in

yum install httpd-dev*

即可解決。

[root@htuidc mod_wsgi-3.4]# make && make install

安裝信息最後會看到生成的mod_wsgi.so庫:

chmod 755 /usr/local/apache/modules/mod_wsgi.so

配置:

修改httpd.conf配置,增加

LoadModule wsgi_module modules/mod_wsgi.so


注意mod_wsgi的要求WSGI應用程序入口點被稱爲“應用程序”。如果你想別的東西,那麼你就需要配置的mod_wsgi的明確使用其他的名稱。因此,不要去隨意改變功能的名稱。如果你這樣做,即使你設置了一切正確的應用程序不會被發現。


HTTP請求處理腳本:

WSGIScriptAlias / /var/www/logpress/index.wsgi

<Directory "/var/www/logpress">

AllowOverride FileInfo

AddHandler mod_python .py

PythonPath "['/var/www/logpress'] + sys.path"

PythonHandler index

PythonDebug On

Order allow,deny

Allow from all

</Directory>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章