Deploying Django with Apache and mod_wsgi Based on Red Hat Enterprise Linux Server

Preconditions:

1. Red Hat Enterprise Linux Server release 5.7 (Tikanga)


STEPs:

1. install gcc, g++ if not

a) Suggest you copy rpm packages from cd-rom: 

    mount /mnt/cdrom /mount/media/

    then, copying and installing these files by order.


2. install or upgrade python:

wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz

mv /usr/bin/python /usr/bin/python_old
ln -s /usr/local/python27/bin/python /usr/bin/

3. Set remi sources for RedHat:

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
vi /etc/yum.repos.d/epel.repo
enabled=1

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
vi /etc/yum.repos.d/remi.repo
#modity enabled to 1
enabled=1

#remove the old yum
rpm -aq|grep yum|xargs rpm -e --nodeps

# download or copy yum packages
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.27-14.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

then:
yum clean All
yum makecache
yum install mysql mysql-server
service mysqld start/stop/restart
mysqladmin -u root password ‘new-password‘
create database test2 default character set utf8 collate utf8_general_ci;

# install mysql-python1.2.5,documents http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/
1. yum install python-devel mysql-devel zlib-devel openssl-devel
2. python setup.py build #Mysql-python source code build
python setup.py install

#install zmq, zmq-python
./configure, make , make check, make install
easy_install pyzmq

#install pycurl, curl
wget http://curl.haxx.se/download/curl-7.24.0.tar.gz
./configure, make, make install
pyCurl:
python setup.py build, install

#install django
python setup.py install

# python manage.py runserve 0.0.0.0:8000 # developing environment

#############  apache & mod_wsgi ######################
download apache source code: http://mirror.bit.edu.cn/apache/httpd/
apr, apr-util: http://mirror.bit.edu.cn/apache/apr/
pcre: http://ftp.exim.llorien.org/pcre/
install arp
tar -zxf apr-1.5.0.tar.gz 
cd apr-1.5.0 
./configure --prefix=/usr/local/apr 
make 
sudo make install 
apr-util
tar –zxvf apr-util-1.5.3.tar.gz 
cd apr-util-1.5.3 
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make 
sudo make install
pcre
unzip –o pcre-8.34.zip 
cd pcre-8.34
./configure --prefix=/usr/local/pcre
make
sudo make install
Apache
tar –zxvf httpd-2.4.7.tar.gz 
cd httpd-2.4.7
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
sudo make install
start Apache,
/usr/local/apache2/bin/apachel start

#install mod_wsgi:
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python
make && make install
chmod 755 /usr/local/apache2/modules/mod_wsgi.so



###### config apache ####################
Listening: 8000
LoadModule wsgi_module modules/mod_wsgi.so
ServerName:192.168.1.23:8000


vi /usr/local/apache/conf/extra/httpd-vhosts.conf


Modify wsgi.py



Check the httpd pid





Deploying Django with Apache and mod_wsgi Based on Red Hat Enterprise Linux Server,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。