一、背景
新开了一个django项目,主要用来做域名管理及暴露API接口进行脚本扫描
二、设置virtualenv
[root@mysql-dev-slave-1 data]# python3 -m venv uwsgi-tutorial
[root@mysql-dev-slave-1 data]# cd uwsgi-tutorial/
[root@mysql-dev-slave-1 uwsgi-tutorial]# source bin/activate
(uwsgi-tutorial) [root@mysql-dev-slave-1 uwsgi-tutorial]# pip install --upgrade pip
(uwsgi-tutorial) [root@mysql-dev-slave-1 uwsgi-tutorial]# pip install Django==3.2.13
三、nginx配置
(uwsgi-tutorial) [root@django vhost]# cat mysite_nginx.conf
upstream django {
#server 127.0.0.1:8000;
server unix:/data/uwsgi-tutorial/domain_admin_site/mysite.sock;
}
server {
listen 8008;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location /static {
# 指定静态文件存放的目录
alias /data/uwsgi-tutorial/domain_admin_site/static/;
}
location / {
uwsgi_pass django;
include /usr/local/openresty/nginx/conf/uwsgi_params;
}
}
四、uwsgi配置
(uwsgi-tutorial) [root@django domain_admin_site]# cat /data/uwsgi-tutorial/domain_admin_site_uwsgi.ini
[uwsgi]
chdir = /data/uwsgi-tutorial/domain_admin_site
wsgi-file = /data/uwsgi-tutorial/domain_admin_site/domain_admin_site/wsgi.py
module = domain_admin_site_uwsgi.ini
home = /data/uwsgi-tutorial
master = true
processes = 1
socket = /data/uwsgi-tutorial/domain_admin_site/mysite.sock
chmod-socket = 666
vacuum = true
#stats = %(chdir)/uwsgi.status
pidfile = %(chdir)/uwsgi.pid
#启动项目
[root@django ~]# source /data/uwsgi-tutorial/bin/activate && uwsgi -d --ini /data/uwsgi-tutorial/domain_admin_site_uwsgi.ini
五、访问测试
应用参考:https://github.com/xiangys0134/deploy/tree/master/django/domain_admin_site
留言