安装配置-Nginx/Uwsgi

Nginx

安装

# Ubuntu
sudo apt update
sudo apt install -y nginx

# 启动
sudo systemctl start nginx
# 停止
sudo systemctl stop nginx
# 查看状态
sudo systemctl status nginx
# 设置自启
sudo systemctl enable nginx
# 关闭自启
sudo systemctl disable nginx

配置

在/etc/nginx/conf.d/下增加配置文件.conf
# file_system.conf
server {
    listen 9090;
    root /home/user/work;
    location /report {
    try_files $uri $uri/ =404;
    autoindex on;
    }
}

# django.conf
server {
        listen       8000;
        server_name  your_domain_or_ip;
        charset utf-8;
        access_log /home/user/work/access.txt;
        error_log /home/user/work/error.txt;
        location / {
            include  uwsgi_params;
            uwsgi_pass  127.0.0.1:9091;
                }
        location /static {
            alias /home/wukn/work/static;
                }
}

Uwsgi

安装

pip3 install uwsgi
# 启动
uwsgi demo.ini
# 停止
ps -ef|grep uwsgi|awk '{print $2}'| xargs kill -9

配置

# demo1.ini
[uwsgi]
#http = 127.0.0.1:9090
socket = 127.0.0.1:9090

chdir = /home/user/myproject
daemonize = %(chdir)/logs/uwsgi.txt
#logto = %(chdir)/myapp.log

module = myproject.wsgi:application
master = true
processes = 4
threads = 2
vacuum = true
die-on-term = true
# demo2.ini
[uwsgi]
# 加载 WSGI 模块
module = myproject.wsgi:application

# 项目目录
chdir = /path/to/your/project

# 网络配置
socket = 127.0.0.1:8000

# 启动进程数和线程数
processes = 4
threads = 2

# 启用 master 进程
master = true

# 设置虚拟环境目录(可选)
# virtualenv = /path/to/your/venv

# 设置守护进程(可选)
# daemonize = /path/to/your/logs/uwsgi.log  # 启用守护进程并记录日志

# 配置日志文件路径(可选)
# logto = /path/to/your/uwsgi.log  # 设置日志文件

# 自动清理环境
vacuum = true

# 接收 TERM 信号后退出
die-on-term = true
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值