/ 中存储网

CentOS下安装Apache2.2.11+django1.02+python2.5

2014-01-11 09:42:01 来源:kejihao

1、安装apache2,顺利进行。

2、安装python2.5,顺利,将原python2.4更名或删除,为与原来保持一至,可做好符号连接

3、安装setuptools: sh setuptools xxx.egg

3、安装mysq-python:easy_install xxx1.2.3.egg

4、安装mod_python3.3.1,

./configure --with-apxs=/usr/local/apache2/bin/apxs

make

make install

这里有个问题:

-I/usr/include/python2.5 -c -o connobject.lo connobject.c && touch

connobject.slo

connobject.c: In function '_conn_read':

connobject.c:142: error: request for member 'next' in something not a structure

or union

apxs:Error: Command failed with rc=65536

.

make[1]: *** [mod_python.so] Error 1

make[1]: Leaving directory `/usr/src/rpm/BUILD/mod_python-3.3.1/src'

make: *** [do_dso] Error 2

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

!(b == APR_BRIGADE_SENTINEL(b)

!(b == APR_BRIGADE_SENTINEL(bb)

5、配置apache

(1)配置基于端口的虚拟主机及整合django

httpd.conf:

Listen 80

Listen 8080

把原httpd下的conf.d借签过来

/usr/local/apache2/conf.d/python.conf:

<VirtualHost *:8080>

<Location "/">

#下面这一句很重要,不加时老是报permission deny,改原来相应位置的权限也没好(当时有些困,或许还有未改到的地方,不过看那个目录也不合适,反正改到这儿挺好用,哈)

SetEnv PYTHON_EGG_CACHE /var/tmp/python

SetHandler python-program

PythonHandler django.core.handlers.modpython

SetEnv DJANGO_SETTINGS_MODULE zzzz.settings

PythonOption django.root /pub/django/

PythonDebug On

PythonPath "['/pub/django/'] + sys.path"

</Location>

</VirtualHost>

Django项目为/pub/django/zzzz

(2)为支持PHP,也借签了conf.d/php.conf

LoadModule php5_module modules/libphp5.so

AddHandler php5-script .php

AddType text/html .php

DirectoryIndex index.php

AddType application/x-httpd-php .php .htm .html

(3)一些优化

httpd.conf:

Include conf/extra/httpd-mpm.conf

#Options Indexes FollowSymLinks

<Directory /pub/htdocs/zzzz>

Order deny,allow

Deny from all

Allow fromx.x.x.x

Allow from x.x.x.x

</Directory>

extra/httpd-mpm.conf:

<IfModule mpm_prefork_module>

StartServers 20

MinSpareServers 20

MaxSpareServers 30

ServerLimit 3000

MaxClients 2000

MaxRequestsPerChild 10000

</IfModule>