ubuntu安装uwsgi

sudo apt-get install python3-dev build-essential libpcre3-dev

 

验证pcre

pcre-config --version

pip install uwsgi

验证uwsgi

mkdir /var/www/pyhtml/root

(需要自己保证一下用户ubuntu有权限)

vi wsgi.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]
uwsgi --http :9090 --wsgi-file wsgi.py

mkdir /var/www/pyhtml/uwsgi
(需要自己保证一下用户ubuntu有权限)
cd /var/www/pyhtml/uwsgi
vi uwsgi.ini
[uwsgi]
http = :9090
#http = 127.0.0.1:9090
chdir = /var/www/pyhtml/root
# /var/www/pyhtml/uwsgi/wsgi.py application
module = wsgi:application
master = True
processes = 1
threads = 2
daemonize = wsgi.log
vacuum = true
pidfile = uwsgi.pid

 

sudo vi /etc/systemd/system/uwsgi.service

 

[Unit]
Description=uWSGI server
After=syslog.target

[Service]
User=ubuntu
WorkingDirectory=/var/www/pyhtml/uwsgi
ExecStart=/home/ubuntu/.local/bin/uwsgi --ini uwsgi.ini
Group=www-data

[Install]
WantedBy=multi-user.target