一个人免费观看视频www中文,女人与公狍交酡女免费,久久99精品久久久久久hb无码,免费人成视频网站在线观看18,亚洲热妇无码av在线播放,好姑娘高清影视在线观看,久久aaaa片一区二区,aaaaa级少妇高潮大片

綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|廠商大全

綠色資源網(wǎng)

技術(shù)教程
您的位置:首頁服務(wù)器類Web服務(wù)器 → CentOS+nginx+uwsgi+Python 多站點(diǎn)環(huán)境搭建

CentOS+nginx+uwsgi+Python 多站點(diǎn)環(huán)境搭建

我要評(píng)論 2013/10/22 16:22:56 來源:綠色資源網(wǎng) 編輯:www.dq05.cn [ ] 評(píng)論:0 點(diǎn)擊:362次

環(huán)境:

CentOS X64 6.4

nginx 1.5.6

Python 2.7.5

一:安裝需要的類庫及Python2.7.5
 

安裝必要的開發(fā)包

yum groupinstall "Development tools"

yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel read LINE -devel tk-devel

CentOS 自帶Python2.6.6,但我們可以再安裝Python2.7.5:

cd ~
wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
tar xvf Python-2.7.5.tar.bz2
cd Python-2.7.5
./configure --prefix=/usr/local
make && make altinstall

安裝完畢后,可是使用”python2.7”命令進(jìn)入python2.7的環(huán)境。

二:安裝Python包管理

easy_install包 https://pypi.python.org/pypi/distribute

方便安裝Python的開發(fā)包

cd ~
wget https://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz
tar xf distribute-0.6.49.tar.gz
cd distribute-0.6.49
python2.7 setup.py install
easy_install --version

紅色部分必須是“python2.7”,否則將安裝到默認(rèn)的2.6環(huán)境內(nèi)。

pip包 https://pypi.python.org/pypi/pip

安裝pip的好處是可以pip list、pip uninstall 管理Python包, easy_install沒有這個(gè)功能,只有uninstall

easy_install pip
pip --version

三:安裝uwsgi

uwsgi:https://pypi.python.org/pypi/uWSGI

uwsgi參數(shù)詳解:http://uwsgi-docs.readthedocs.org/en/latest/Options.html

pip install uwsgi
uwsgi --version

測試uwsgi是否正常:

新建test.py文件,內(nèi)容如下:

def application(env, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return "Hello World"

然后在終端運(yùn)行:

uwsgi --http :8001 --wsgi-file test.py

在瀏覽器內(nèi)輸入:http://127.0.0.1:8001,看是否有“Hello World”輸出,若沒有輸出,請(qǐng)檢查你的安裝過程。

四:安裝django

pip install django

測試django是否正常,運(yùn)行:

django-admin.py startproject demosite
cd demosite
python2.7 manage.py runserver 0.0.0.0:8002

在瀏覽器內(nèi)輸入:http://127.0.0.1:8002,檢查django是否運(yùn)行正常。

五:安裝nginx

cd ~
wget http://nginx.org/download/nginx-1.5.6.tar.gz
tar xf nginx-1.5.6.tar.gz
cd nginx-1.5.6
./configure --prefix=/usr/local/nginx-1.5.6 \
--with-http_stub_status_module \
--with-http_gzip_static_module
make && make install

六:配置uwsgi

uwsgi支持ini、xml等多種配置方式,但個(gè)人感覺ini更方便:

在/ect/目錄下新建uwsgi9090.ini,添加如下配置:

[uwsgi]
socket = 127.0.0.1:9090
master = true         //主進(jìn)程
vhost = true          //多站模式
no-stie = true        //多站模式時(shí)不設(shè)置入口模塊和文件
workers = 2           //子進(jìn)程數(shù)
reload-mercy = 10     
vacuum = true         //退出、重啟時(shí)清理文件
max-requests = 1000   
limit-as = 512
buffer-sizi = 30000
pidfile = /var/run/uwsgi9090.pid    //pid文件,用于下面的腳本啟動(dòng)、停止該進(jìn)程
daemonize = /website/uwsgi9090.log

設(shè)置uwsgi開機(jī)啟動(dòng),在/ect/init.d/目錄下新建uwsgi9090文件,內(nèi)容如下:

#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for uwsgi webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add uwsgi'
 
### BEGIN INIT INFO
# Provides:          uwsgi
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the uwsgi web server
# Description:       starts uwsgi using start-stop-daemon
### END INIT INFO
 
# Author:   licess
# website:  http://lnmp.org
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="uwsgi daemon"
NAME=uwsgi9090
DAEMON=/usr/local/bin/uwsgi
CONFIGFILE=/etc/$NAME.ini
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
 
set -e
[ -x "$DAEMON" ] || exit 0
 
do_start() {
    $DAEMON $CONFIGFILE || echo -n "uwsgi already running"
}
 
do_stop() {
    $DAEMON --stop $PIDFILE || echo -n "uwsgi not running"
    rm -f $PIDFILE
    echo "$DAEMON STOPED."
}
 
do_reload() {
    $DAEMON --reload $PIDFILE || echo -n "uwsgi can't reload"
}
 
do_status() {
    ps aux|grep $DAEMON
}
 
case "$1" in
 status)
    echo -en "Status $NAME: \n"
    do_status
 ;;
 start)
    echo -en "Starting $NAME: \n"
    do_start
 ;;
 stop)
    echo -en "Stopping $NAME: \n"
    do_stop
 ;;
 reload|graceful)
    echo -en "Reloading $NAME: \n"
    do_reload
 ;;
 *)
    echo "Usage: $SCRIPTNAME {start|stop|reload}" >&2
    exit 3
 ;;
esac
 
exit 0

然后在終端執(zhí)行:

-- 添加服務(wù)
chkconfig --add uwsgi9090 
-- 設(shè)置開機(jī)啟動(dòng)
chkconfig uwsgi9090 on

七:設(shè)置nginx

找到nginx的安裝目錄,打開conf/nginx.conf文件,修改server配置

server {
        listen       80;
        server_name  localhost;
        
        location / {            
            include  uwsgi_params;
            uwsgi_pass  127.0.0.1:9090;              //必須和uwsgi中的設(shè)置一致
            uwsgi_param UWSGI_SCRIPT demosite.wsgi;  //入口文件,即wsgi.py相對(duì)于項(xiàng)目根目錄的位置,“.”相當(dāng)于一層目錄
            uwsgi_param UWSGI_CHDIR /demosite;       //項(xiàng)目根目錄
            index  index.html index.htm;
            client_max_body_size 35m;
        }
    }

設(shè)置nginx開機(jī)啟動(dòng),在/ect/init.d/目錄下新建nginx文件,內(nèi)容如下:

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /var/run/nginx.pid
  
# Source function library.
. /etc/rc.d/init.d/functions
  
# Source networking configuration.
. /etc/sysconfig/network
  
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
  
nginx="/opt/nginx-1.5.6/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/opt/nginx-1.5.6/conf/nginx.conf"
  
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  
lockfile=/var/lock/subsys/nginx  
 
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
  
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
  
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
  
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
  
force_reload() {
    restart
}
  
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
  
rh_status() {
    status $prog
}
  
rh_status_q() {
    rh_status >/dev/null 2>&1
}
  
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|f                    

關(guān)鍵詞:CentOS,nginx,uwsgi,Python

閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!

  • 2 歡迎喜歡
  • 1 白癡
  • 1 拜托
  • 1 哇
  • 2 加油
  • 1 鄙視
主站蜘蛛池模板: 国产福利日本一区二区三区| 漂亮的人妻少妇| 四房播色| 丰满的已婚女人hd中字 | 性夜影院爽黄a爽av| 久久久久久久久无码精品亚洲日韩 | 亚洲一卡2卡三卡4卡高清| 国产日产欧产美韩系列麻豆| 国产精品视频啊啊| 加勒比hezyo黑人专区| 日本xxxxx片免费观看| 成人伊人精品色xxxx视频| 日韩伦理片| japanese无码中文字幕| 女人18片毛片60分钟| 老子影院午夜精品无码| 国产欧美日韩精品丝袜高跟鞋| 国产免费视频| 挺进邻居人妻雪白的身体韩国电影| 国产亚洲精品久久久久妲己| 亚洲欧美一区二区三区在线| 果冻传媒在线看免费高清| 高清免费卡一卡二新区| 男人的天堂av网站| 国产成人亚洲综合色就色 | 极品少妇被弄得高潮不断| bestialitysexvideo另类蛇交| 最近的2019中文字幕国语hd| 日本一道本| 1区2区3区4区产品乱码入口| japan丰满人妻hd| 免费a级毛片出奶水| a毛看片免费观看视频| 野花免费观看日本韩国| 好爽...又高潮了毛片| 久久精品国产亚洲av无码偷窥| 亚洲人成电影在线天堂色| 另类 专区 欧美 制服丝袜| 亚洲一区二区观看播放| www.夜夜操.com| 国产成人亚洲精品无码h在线 |