欢迎使用CSDN-markdown编辑器

来源:互联网 发布:代理服务器软件 开源 编辑:程序博客网 时间:2024/06/05 06:15

1. 安装uWSGI

`pip install uwsgi`

阿里云ubuntu自带python2.7,在安装WSGI之前需要安装新版本的python,如python3.6,同时也要将Django项目中需要引用的包安装完成。

2.uWSGI配置文件

在uwsgi的文件夹中建立配置文件:
cd /etc/uwsgi/sites
如果没有sites文件夹,可以先创建该文件夹 mkdir 文件名
然后创建并编辑文件
vim project.ini

[uwsgi]http = :8000# the base directory (full path)chdir = /root/path/to/project# Django s wsgi filemodule = project.wsgimaster = true# maximum number of worker processesprocesses = 4# ... with appropriate permissions - may be neededvacuum = true

3.Nginx的安装和配置

安装

apt-get install nginx

创建配置文件
vim /etc/nginx/sites-available/project

server {    listen 8001;    server_name ip;  #服务器公网ip    access_log /var/log/nginx/myweb_access.log;    error_log /var/log/nginx/myweb_error.log;    location /static/ {    root root/path;#静态文件地址    }   client_max_body_size 75M;    location / {        include uwsgi_params;        uwsgi_pass unix:/path/project.sock;               }}

4.启动

启动nginx:service nginx restart
启动uwsgi:uwsgi /etc/uwsgi/sites/project.ini

原创粉丝点击