linux服务器部署(以django项目为例)(三)
  pfl0iGEgXbv6 2023年11月02日 37 0

uwsgi:

pip3 install uwsgi

这里可能会遇到报错

#有些是
yum remove openssl-devel
#有些是
 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel  tk-devel pcre-devel

自行尝试

命令参数:

[uwsgi]
socket = 127.0.0.1:8001
chdir = /root/day03/
wsgi-file = day03/wsgi.py
processes = 4
virtualenv = /envs/nb/

touch uwsgi_day03.ini

vim uwsgi_day03.ini

linux服务器部署(以django项目为例)(三)_nginx

启动

uwsgi --ini uwsgi_day03.ini

linux服务器部署(以django项目为例)(三)_nginx_02

后台运行:

uwsgi --ini uwsgi_day03.ini &

nginx:

yum install nginx -y

当然你也可以选择源码装

配置文件:

/etc/nginx/nginx.conf

启动:

systemctl start nginx

请自行配置

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    # include /etc/nginx/conf.d/*.conf;

    upstream django {
    #这是uwsgi你自己定义的
        server 127.0.0.1:8001;
    }

    server {
        listen       80;
        listen       [::]:80;
        #这里显示域名
        server_name  _;

        # Load configuration files for the default server block.
        # include /etc/nginx/default.d/*.conf;
        #自行配置
		location /static {
            alias  /root/allstatic;
        }

        location / {
            uwsgi_pass  django;
            include     uwsgi_params;
        }

    }
}

备份:

linux服务器部署(以django项目为例)(三)_nginx_03

vim nginx.conf

systemctl restart nginx

linux服务器部署(以django项目为例)(三)_nginx_04

看这篇:https://blog.csdn.net/weixin_44621066/article/details/103912753

linux服务器部署(以django项目为例)(三)_nginx_05

同时启动uwsgi:

uwsgi --ini uwsgi_day03.ini &

开机自启:

systemctl enable nginx

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: python 函数的调用(二) 下一篇: pg启动
  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  4JlQwvcFgfj9   2023年12月11日   23   0   0 djangoldap
  jnZtF7Co41Wg   2023年12月11日   29   0   0 nginx客户端服务端
  YKMEHzdP8aoh   2023年11月30日   33   0   0 vimUDP
  stLBpDewCLT1   2023年12月08日   28   0   0 nginx
  jnZtF7Co41Wg   2023年12月10日   22   0   0 nginx客户端服务端NFS
  eHipUjOuzYYH   2023年12月06日   26   0   0 nginxHTTP
  eHipUjOuzYYH   2023年12月06日   22   0   0 nginx加载IPV6