下载nginx
- yum install nginx
- rpm -ql nginx
- systemctl start nginx
- /usr/share/nginx/html # html页面
- /etc/nginx/nginx.conf # nigix配置文件
- systemctl restart nginx # 重启nginx服务
下载Python
- yum install wget openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc-c++ -y # 安装编译器
- yum install libxml* -y # 安装编译器
- 上传Python-3.6.3.tgz包
- tar xf Python-3.6.3.tgz
- cd Python-3.6.3.tgz
- ./configure --prefix=/usr/local/python3 # 修改配置文件
- make -j2 # 编译
- make install -j2 # 编译
- ln -s /usr/local/python3/bin/python3 /usr/bin/python3 # 把python3加入环境变量
- ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 # 把pip3加入环境变量
- pip3 install uwsgi # 下载uwsgi
- ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi3
- 写一个footbar.py
文件
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
查看uwsgi能否正常启动
- uwsgi3 --http :9091 --wsgi-file footbar.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191 # 9091端口开启服务
安装并查看django能否正常启动
- pip install django
- /usr/local/python3/bin/django-admin startproject mysite
- cd mysite/
- python3 manage.py runserver 0.0.0.0:9000
- vim settings.py
- hosts修改成*.*
用nginx代理访问django
- 修改/etc/nginx/nginx.conf文件
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9091;
}
- uwsgi3 --socket 127.0.0.1:9000 --module mysite.wsgi
- vim uwsgi.ini
[uwsgi]
chdir=/root/mysite
module=mysite.wsgi
master=true
processes=10
socket=127.0.0.1:9000
- uwsgi3 uwsgi.ini 我这是纯代码的,一路复制粘贴下来应该没问题,可以用markdown打开