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

Source: Internet
Author: User
Tags install django


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





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.