0%

centos7-+-django+vue

开放端口

1
2
3
4
5
6
7
8
firewall-cmd --zone=public --add-port=8100/tcp --permanent
firewall-cmd --reload # 配置立即生效
firewall-cmd --zone=public --list-port # 查看防火墙所有开放的端口
firewall-cmd --state # 查看防火墙状态
netstat -lnpt # 查看监听的端口
netstat -lnpt |grep 5672 # 查看监听的具体端口


  • 编写和启动脚本start.sh,启动sh start.sh
    1
    2
    3
    4
    5
    # 后台启动django服务,输出日志到日志文件中,内容为标准输出和标准错误
    MYDATE=`date +%Y%m%d`
    ALL_LOGFILE=/usr/local/log/log_$MYDATE

    nohup python3 manage.py runserver 0.0.0.0:8100 > ${ALL_LOGFILE} 2>&1 &

按照nginx

  • 按照依赖文件

    1
    2
    3
    4
    5
    yum install gcc-c++
    yum install -y pcre pcre-devel
    yum install -y zlib zlib-devel
    yum install -y openssl openssl-devel

  • 配置nginx

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
    tar -zxvf nginx-1.10.1.tar.gz
    cd nginx-1.10.1
    ./configure # 使用默认配置
    # 编辑安装
    make
    make install

    whereis nginx # 查询安装路径
    # 启动、停止nginx
    cd /usr/local/nginx/sbin/
    ./nginx # 启动
    ./nginx -t # 检查
    ./nginx -s stop
    ./nginx -s quit
    ./nginx -s reload
  • 修改配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    vim nginx.conf



    #user nobody;
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    #pid logs/nginx.pid;

    events {
    worker_connections 1024;
    }

    http {
    include mime.types;
    default_type application/octet-stream;

    #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 logs/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;
    #upstream表示负载服务器池,定义名字为goserver的服务器池
    #upstream goserver {
    # server 47.123.15.125:8887 weight=7;
    # server 192.111.50.133:8888 weight=3;
    #}
    #基于域名的虚拟主机
    server {
    #8880为监听端口号
    listen 8880;
    server_name 192.168.111.128;
    index index.html index.htm;
    #root 是你的访问目录
    root /home/dist;
    #charset koi8-r;

    #access_log logs/host.access.log main;

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    # root html;
    # fastcgi_pass 127.0.0.1:9000;
    # fastcgi_index index.php;
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    # include fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}
    }
    }


  • 关掉防火墙的端口

    1
    2
    3
    4
    5
    //8088,自己指定端口
    firewall-cmd --permanent --add-port=8880/tcp --zone=public
    //重新加载
    firewall-cmd --reload

  • 重启nginx

    1
    2
    3
    4
    5
    //检查配置是否正确
    ./nginx -t
    //启动nginx
    ./nginx

  • 前台正常访问
    image.png