centos中使用LuManager部署Django应用
作者:我就是个世界
发表于:2012-11-07
[b]centos部署feifanlv.com[/b]
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
sh setuptools-0.6c11-py2.6.egg
easy_install virtualenv
yum install python-devel libxml2 MySQL-python
python-mysql安装
wget http://sourceforge.net/projects/mysql-python/files/latest/download?source=files
tar -zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python setup.py build
python setup.py install
cd /home
virtualenv feifanlv
cd feifanlv
source ./bin/activate
pip install pil uwsgi django django-tagging django-uni-form
安装LuManager
1. 下载zijidelu_install.sh安装脚本:wget http://down.zijidelu.org/zijidelu_install.sh(FreeBSD系统则用fetch代替wget)
2. 赋予zijidelu_install.sh可执行权限:chmod 740 zijidelu_install.sh(或者chmod u+x zijidelu_install.sh)
3. 安装:./zijidelu_install.sh -y(此为全自动安装,如需半自动安装,请不用-y参数,即:./zijidelu_install.sh)
如果您希望PHP支持pdo和mysqli,请用两个-y参数,即:./zijidelu_install.sh -y -y,但由于兼容性方面的因素,在某些机器上可能装不成功
其中第1、2、3步可合并执行(FreeBSD则用fetch代替wget):
wget http://down.zijidelu.org/zijidelu_install.sh; chmod 740 zijidelu_install.sh; ./zijidelu_install.sh -y
4. 选择下载点:China的为中国电信下载点(默认),USA为美国下载点。选择好后回车
5. 选择您要安装的版本:选择好回车即可。如果是Redhat系列系统,会提示您是否用rpm包来快速安装LuNamp,建议时间比较紧或编译安装失败的用户选择rpm包进行安装
提示:如果在安装过程中断网,请重新执行安装便可(已经安装的会跳过)
上传/usr/local/nginx/conf/django_uwsgi.conf
-----------------------------------
# Django project
server {
listen 80;
server_name www.feifanlv.com feifanlv.com;
if ($host = 'feifanlv.com' ) {
rewrite ^/(.*)$ http://www.feifanlv.com/$1 permanent;
}
location / {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
access_log off;
}
location ^~ /static {
root /home/feifanlv/travelsite;
}
location ^~ /admin/ {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
access_log off;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
root /home/feifanlv/travelsite/static;
access_log off;
}
}
-----------------------------------
/usr/local/nginx/conf/nginx.conf追加子配置文件django_uwsgi.conf
-----------------------------------
http{
........
include django_uwsgi.conf;
}
-----------------------------------
UWSGI配置
mkdir -p /home/feifanlv/uwsgi;cd /home/feifanlv/uwsgi
mkdir -p /home/feifanlv/logs
echo "" > /home/feifanlv/logs/django.log
vi uwsgi.xml
-----------------------------------
127.0.0.1:3031
200
true
/usr/local/nginx/uwsgi.pid
8
/home/feifanlv/travelsite
/home/feifanlv/
django_wsgi
true
true
true
true
256
/home/feifanlv/logs/django.log
8、启动与关闭服务
uwsgi -x /home/feifanlv/uwsgi/uwsgi.xml
/usr/local/nginx/sbin/nginx
killall -9 uwsgi #关闭uwsgi服务
/usr/local/nginx/sbin/nginx -s reload #平滑重启
9、查看进程
ps -ef|grep uwsgi|grep -v grep
10、监听端口
netstat -an|grep 3031
维护重启服务:
cd /home/feifanlv
source ./bin/activate
ps -ef|grep uwsgi|grep -v grep
killall -9 uwsgi
sh /home/feifanlv/uwsgi/uwsgiserver.sh start
/usr/local/nginx/sbin/nginx -s reload
---------------------------------------------------
如果报错502,NGINX日志显示:
2012/02/18 13:12:39 [error] 1383#0: *198 upstream prematurely closed connection while reading response header from upstream, client: 60.220.178.174, server: w.feifanlv.com, request: "GET /favicon.ico/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "w.feifanlv.com"
说明uwsgi内存配置有问题,请参照服务器硬件情况进行修改
----------------------------------------------------------
参考:
Centos5.4+Nginx-0.8.50+UWSGI-0.9.6.2+Django-1.2.3搭建高性能WEB服务器[原创]
http://blog.liuts.com/post/216/
---------------------------------------------------------------
配置防火墙
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15900 -j ACCEPT(允许15900端口通过防火墙)
重启防火墙,使刚才的端口配置生效
/etc/init.d/iptables restart
或者
service iptables restart
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
sh setuptools-0.6c11-py2.6.egg
easy_install virtualenv
yum install python-devel libxml2 MySQL-python
python-mysql安装
wget http://sourceforge.net/projects/mysql-python/files/latest/download?source=files
tar -zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python setup.py build
python setup.py install
cd /home
virtualenv feifanlv
cd feifanlv
source ./bin/activate
pip install pil uwsgi django django-tagging django-uni-form
安装LuManager
1. 下载zijidelu_install.sh安装脚本:wget http://down.zijidelu.org/zijidelu_install.sh(FreeBSD系统则用fetch代替wget)
2. 赋予zijidelu_install.sh可执行权限:chmod 740 zijidelu_install.sh(或者chmod u+x zijidelu_install.sh)
3. 安装:./zijidelu_install.sh -y(此为全自动安装,如需半自动安装,请不用-y参数,即:./zijidelu_install.sh)
如果您希望PHP支持pdo和mysqli,请用两个-y参数,即:./zijidelu_install.sh -y -y,但由于兼容性方面的因素,在某些机器上可能装不成功
其中第1、2、3步可合并执行(FreeBSD则用fetch代替wget):
wget http://down.zijidelu.org/zijidelu_install.sh; chmod 740 zijidelu_install.sh; ./zijidelu_install.sh -y
4. 选择下载点:China的为中国电信下载点(默认),USA为美国下载点。选择好后回车
5. 选择您要安装的版本:选择好回车即可。如果是Redhat系列系统,会提示您是否用rpm包来快速安装LuNamp,建议时间比较紧或编译安装失败的用户选择rpm包进行安装
提示:如果在安装过程中断网,请重新执行安装便可(已经安装的会跳过)
上传/usr/local/nginx/conf/django_uwsgi.conf
-----------------------------------
# Django project
server {
listen 80;
server_name www.feifanlv.com feifanlv.com;
if ($host = 'feifanlv.com' ) {
rewrite ^/(.*)$ http://www.feifanlv.com/$1 permanent;
}
location / {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
access_log off;
}
location ^~ /static {
root /home/feifanlv/travelsite;
}
location ^~ /admin/ {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
access_log off;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
root /home/feifanlv/travelsite/static;
access_log off;
}
}
-----------------------------------
/usr/local/nginx/conf/nginx.conf追加子配置文件django_uwsgi.conf
-----------------------------------
http{
........
include django_uwsgi.conf;
}
-----------------------------------
UWSGI配置
mkdir -p /home/feifanlv/uwsgi;cd /home/feifanlv/uwsgi
mkdir -p /home/feifanlv/logs
echo "" > /home/feifanlv/logs/django.log
vi uwsgi.xml
-----------------------------------
8、启动与关闭服务
uwsgi -x /home/feifanlv/uwsgi/uwsgi.xml
/usr/local/nginx/sbin/nginx
killall -9 uwsgi #关闭uwsgi服务
/usr/local/nginx/sbin/nginx -s reload #平滑重启
9、查看进程
ps -ef|grep uwsgi|grep -v grep
10、监听端口
netstat -an|grep 3031
维护重启服务:
cd /home/feifanlv
source ./bin/activate
ps -ef|grep uwsgi|grep -v grep
killall -9 uwsgi
sh /home/feifanlv/uwsgi/uwsgiserver.sh start
/usr/local/nginx/sbin/nginx -s reload
---------------------------------------------------
如果报错502,NGINX日志显示:
2012/02/18 13:12:39 [error] 1383#0: *198 upstream prematurely closed connection while reading response header from upstream, client: 60.220.178.174, server: w.feifanlv.com, request: "GET /favicon.ico/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "w.feifanlv.com"
说明uwsgi内存配置有问题,请参照服务器硬件情况进行修改
----------------------------------------------------------
参考:
Centos5.4+Nginx-0.8.50+UWSGI-0.9.6.2+Django-1.2.3搭建高性能WEB服务器[原创]
http://blog.liuts.com/post/216/
---------------------------------------------------------------
配置防火墙
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15900 -j ACCEPT(允许15900端口通过防火墙)
重启防火墙,使刚才的端口配置生效
/etc/init.d/iptables restart
或者
service iptables restart
请发表您的评论