nginx+uwsgi+django-zhenj8nanzhuce
以下操作全在root下操作,不是必须。nginx使用淘宝开发tengin。更新依赖:
yum update -y
yum groupinstall "Development Tools" -y
yum groupinstall "Perl Support" -y
yum install ntpdate zlib libjpeg libpng curl zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel apr apr-util autoconf freetype gd libxslt libxslt-devel libxml2 openssl* ncurses ncurses-devel tree curl lrzsz dos2unix gcc gcc-c++ dstat e2fsprogs-devel flex flex-devel libtiff-devel pam-devel uuid libffi-devel dstat -y
下载源码包:
wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz
wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/master.zip
安装Tengin及Lua语言依赖(Lua依赖可以不装,个人需求):
tar xf pcre-8.39.tar.gz
cd pcre-8.39
./configure --prefix=/usr/local/pcre
make && make install
cd ..
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make && make install
cd ..
tar xf LuaJIT-2.0.3.tar.gz
cd LuaJIT-2.0.3
make && make install
echo "export LUAJIT_LIB=/usr/local/lib" >>/etc/profile
echo "export LUAJIT_INC=/usr/local/include/luajit-2.0" >>/etc/profile
source /etc/profile
cd ..
tar xf v0.3.0.tar.gz
unzip master.zip
useradd nginx
tar xf tengine-2.1.2.tar.gz
cd tengine-2.1.2
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-pcre=/root/pcre-8.39 \
--with-http_gzip_static_module \
--with-http_concat_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-zlib=/root/zlib-1.2.8 \
--add-module=/root/lua-nginx-module-master \
--add-module=/root/ngx_devel_kit-0.3.0
make
make install
cd ..
echo "/usr/local/lib/" >>/etc/ld.so.conf
ldconfig
安装python2.7以上版本:
wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
mv /usr/bin/python /usr/bin/python26
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure
make -j8 && make install
ln-s /usr/local/bin/python2.7 /usr/bin/python
# python -V // check version
sed -i "s#\#\!/usr/bin/python#\#\!/usr/bin/python26#g" /usr/bin/yum
安装pip&uwsgi&django:
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
pip install --upgrade pip
pip install uwsgi
pip install django
创建django项目:
Reference:http://784687488.blog.51cto.com/8774365/1897368
配置uwsgid.ini:
cat >>/etc/uwsgid.ini/etc/init.d/uwsgid else
echo "Nginx service does not started."
fi
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
> $1
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 2
esac
EOF
启动:
/etc/init.d/uwsgi start
/etc/init.d/nginx start
netstat -lntp|egrep "18000|80"
tcp 0 0 0.0.0.0:18000 0.0.0.0:* LISTEN 25776/uwsgi
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4272/nginx
注:安装配置比较简单,没做注释,有不理解的可以给我留言。
页:
[1]