下載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
文件html
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打開