快速搭建一个restful接口服务

部署到阿里云服务器 - 一站式服务

2018-04-19  本文已影响0人  一颗老不死的心

增加nginx配置文件和uwsgi配置文件

server {
    listen 80;
    server_name tianruoliang.cn;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name tianruoliang.cn;
    client_max_body_size 10M;
    access_log /var/log/nginx/tianruoliang.cn-access.log;
    error_log /var/log/nginx/tianruoliang.cn-error.log;

    ssl on;
    ssl_certificate   cert/214493081740327.pem;
    ssl_certificate_key  cert/214493081740327.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

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

}

server {
    listen 80;
    server_name www.tianruoliang.cn;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.tianruoliang.cn;
    client_max_body_size 10M;
    access_log /var/log/nginx/tianruoliang.cn-access.log;
    error_log /var/log/nginx/tianruoliang.cn-error.log;

    ssl on;
    ssl_certificate   cert/214493081740327.pem;
    ssl_certificate_key  cert/214493081740327.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location / {
        root /var/www/tianruoliang.cn/;
        autoindex on;
        index index.html;
    }

    location ~ /static/ {
        root /var/www/tianruoliang.cn/;
        expires 30d;
    }

}

uwsgi.ini

[uwsgi]
vhost = false
socket = 0.0.0.0:9001
chmod-socket = 666
master = true
vacuum = true
enable-threads = true
threads = 2
processes = 3
callable = app
wsgi-file = /usr/www/trl_home/trlapi/wsgi.py
virtualenv = /usr/www/trl_home/venv
chdir = /usr/www/trl_home
gevent = 100
disable-logging = true
log-maxsize = 100000000
daemonize = /var/log/tianruoliang-uwsgi.log
uid = root
gid = root

进入我的服务器

安装相应的服务

cd /project_path
git clone https://github.com/tianruoliang/trl_home.git
cd trl_home
virtualenv venv -p python2
. venv/bin/activate
pip install -e .
mysql -u user -p < schema.sql
export MYSQL_USER='user'
export MYSQL_PWD='password'
export TRLAPI_CONFIG='configpro.py'
trlapi init
cp tianruoliang-nginx.conf /etc/nginx/sites-available/
ln -s /etc/nginx/sites-available/tianruoliang-nginx.conf /etc/nginx/sites-enabled
nginx -t   (监测是否正常)
nginx -s reload
uwsgi -i tianruoliang-uwsgi.ini
上一篇下一篇

猜你喜欢

热点阅读