1. 安装python
$ sudo pacman -S python
$ mkdir ~/.pip
$ echo '[global]' > ~/.pip/pip.conf
$ echo 'index-url = https://pypi.tuna.tsinghua.edu.cn/simple' >> ~/.pip/pip.conf
2. 创建web目录
$ sudo mkdir -p /www/wwwroot/test/uwsgi
3. 创建test.py
$ sudo pip install flask
$ vim /www/wwwroot/test/test.py
====================================
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello, World!"
if __name__ == '__main__':
app.run(host='0.0.0.0')
4. 配置nginx
$ sudo pacman -S nginx
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf_backup
$ sudo vim /etc/nginx/nginx.conf
c============== 找到 location / { 段,改为 ====================c
location / {
include uwsgi_params;
uwsgi_pass unix:/www/wwwroot/test/uwsgi/uwsgi.sock;
}
$ sudo pip install uwsgi
5. 配置uwsgi
$ sudo pip install uwsgi
$ touch /www/wwwroot/test/uwsgi/{uwsgi.sock,uwsgi.status,uwsgi.pid,uwsgi.log}
$ vim /www/wwwroot/test/uwsgi.ini
========================================
[uwsgi]
chdir = /www/wwwroot/test
home = /www/wwwroot/test/.env
module = test
callable = app
master = true
processes = 2
# chmod-socket = 666
# logfile-chmod = 664
procname-prefix-spaced = test
py-autoreload = 1
# http = 0.0.0.0:8080
vacuum = true
socket = %(chdir)/uwsgi/uwsgi.sock
stats = %(chdir)/uwsgi/uwsgi.status
pidfile = %(chdir)/uwsgi/uwsgi.pid
daemonize = %(chdir)/uwsgi/uwsgi.log
6. 启动uwsgi
$ sudo chown http:http -R /www
$ sudo uwsgi --ini /www/wwwroot/test/uwsgi.ini
7. 参考
https://www.bilibili.com/video/BV1CJ411y7AW?from=search&seid=12835791166125293576