安装必要的软件

apt-get update
apt-get -y install apt-utils

# Nginx
apt-get -y install nginx

# Python and pip
apt-get -y install python
apt-get -y install curl
apt-get -y install python-pip

# uWsgi
apt-get -y install g++
apt-get -y install python-dev
pip install uwsgi

# Django & Python Module
pip install Django==1.8.6
apt-get -y install python-mysqldb
pip install pymongo=="2.8"
pip install mongoengine

除了使用pip安装uwsgi外,可以用apt-get安装

apt-get -y install uwsgi
apt-get -y install uwsgi-plugin-python

建立Nginx配置文件

server {
    listen 80;
    server_name default_server;

    root /var/www/html/;
    #index index.html;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9001;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
}

启动uwsgi和nginx

uwsgi --socket 127.0.0.1:9001 --chdir /var/www/objst/src/ --wsgi-file xglabc/cloud/objstorage/gateway/wsgi.py --processes 4 --threads 2 &

如果uwsgi是使用apt-get安装的需要在命令行添加如下--plugin python参数,不然会出现uwsgi: unrecognized option '--wsgi-file'错误

uwsgi --socket 127.0.0.1:9001 --chdir /var/www/objst/src/ --plugin python --wsgi-file xglabc/cloud/objstorage/gateway/wsgi.py --processes 4 --threads 2 &

启动Nginx

/etc/init.d/nginx start

[ 编辑 | 历史 ]
最近由“jilili”在“2016-10-26 08:25:31”修改