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

本文详细介绍了如何在Red Hat Enterprise Linux Server release 5.7(Tikanga)上安装GCC、更新Python、配置资源、安装MySQL、部署Django、配置Apache及mod_wsgi等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值