Notes
  • 简介
  • Linux
    • Ubuntu
      • Ubuntu 20.04 ARM64 修改PAGE_SIZE 64k
    • Samba
      • CentOS7安装Samba
      • 简单案例
      • 审计
      • 相关命令
    • Systemd
    • FPM 打包 nginx rpm 包
    • rpm 打包-从二进制文件进行打包
    • Centos7 重置密码
    • CentOS7搭建kvm并创建虚拟机
    • CentOS7-KVM 嵌套虚拟化
    • CentOS7 KVM GPU 穿透
    • Bonding
    • CentOS7 发送邮件
    • CentOS7 安装 OpenVPN
    • Linux 多线路由策略
    • Webmin 安装
    • NoVNC 安装
    • SRS-RTMP 服务部署
    • CentOS7 安装 MongoDB
    • confluence 安装
    • jira 安装
    • crowd 安装
    • ScriptRunner For Jira
    • ScriptRunner For Confluence
    • Ubuntu VNC
    • Ubuntu18.04-VNC 安装
    • deb 打包
    • iptables
    • debian 保持软件包一致
    • Ubuntu18.04 编译安装 grpc
    • CentOS7 安装 odoo13
    • Pacemaker 入门
    • Firewalld Rich Language
    • PHP Xdebug
    • CentOS7.3 编译安装 Python3.6
    • 葫芦儿打包
    • CentOS7 安装 Tomcat8
    • CentOS7 安装 JDK
    • GuacamoleServer 编译安装
    • FreeBSD7.0安装AMP
    • CentOS7 换源
    • deb下载并离线安装
    • pip下载并离线安装
  • Network
    • 案例一
  • AI
    • 微调Qwen2.5
    • Qwen2.5 VL AWQ量化
    • qwen2.5 填充权重
  • JavaScript
  • Zabbix
    • CentOS7 安装 Zabbix4.0 LTS
    • Zabbix 加密连接
    • Zabbix 主动和被动模式
    • Zabbix 配置邮件报警
    • Zabbix 监控 MySQL
  • 数据库
    • MySQL
      • CentOS7 Install MySQL5.7
      • MySql 主从配置
      • CentOS7 安装 Percona XtraDB Cluster
      • MySql 压力测试-sysbench
      • MariaDB Galera Cluster
      • 备份脚本
    • MongoDB
      • 启用账号密码登录
      • 备份脚本
  • Nginx
    • CentOS7 安装 Nginx
    • Nginx 配置
    • nginx-http-flv-module
    • Nginx-WebDAV
  • Docker
    • CentOS7 安装 Docker
    • Dockerfile
    • DockerSwarm 集群
    • Docker 安装 guacamole
  • Python
    • 虚拟环境
  • Windows
    • Windows 问题集合
    • 迅雷自动安装 Chrome 插件
    • RDP 注册表
    • Rdp File Setting
    • 本地组策略对象(LGPO)工具
    • 禁用应用联网
    • SQL Server 问题处理
    • SQL Server Trigger
    • NSIS 脚本
    • 使用QEMU运行ARM64 CentOS7
    • DOS 脚本
    • Windows 11 设置旧版右键菜单
    • 远程桌面二次验证
  • Apple
    • AppStore 应用开发及上架
    • Apple 打包 Golang WebDav 制作 pkg 安装包
  • Android
    • Android Studio创建具有root权限的虚拟机
    • Android读写挂载system
    • Android安卓CA至系统
  • 证书
    • 证书名称(主题)
    • 证书扩展
    • SSL 自签
    • 免费 https 证书申请
  • 树莓派
    • 树莓派系统烧录及系统打包制作
    • 树莓派基础操作
    • 树莓派安装 NextCloud
    • 树莓派安装 LNMP
    • 树莓派自定义开机界面和登录提示
    • 树莓派安装 HomeAssistant
    • HomeAssistant 配置
    • 树莓派自动挂载 U 盘
    • 树莓派安装 vsftpd
    • vsftpd 配置文件详解
  • ceph
    • ceph-deploy 部署 ceph nautilus 版本
    • ceph dashboard
  • OpenStack
    • OpenStack VM 配置 Virtual IP
    • OpenStack Glance 对接 Ceph RBD 存储
    • OpenStack Cinder Volumes 对接 Ceph RBD 存储
    • OpenStack 集群搭建
    • OpenStack Rocky 单节点部署
    • OpenStack Rocky 集群部署
    • OpenStack CentOS6 镜像制作
    • OpenStack-Ubuntu 镜像制作
    • Openstack-Windows 镜像制作
    • OpenStack-RBD 导入镜像
    • OpenStack-Rocky 灾备
    • rbd-mirror
  • FFmpeg
    • CentOS7 静态编译FFmpeg
    • MacOS10.12静态编译FFmpeg
    • CentOS7 Arm64静态编译FFmpeg
    • 使用NVIDIA显卡
    • 脚本
  • Other
    • 华为一碰传标签制作
    • 常用软件
    • wireguard
由 GitBook 提供支持
在本页
  • 配置 python3.6
  • 配置 nginx
  • 配置 redis
  • 配置 celery
  • 配置 uwsgi
  • 打包
  1. Linux

葫芦儿打包

操作系统:CentOS7.6.1810

  • 关闭SELinux

    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
  • 创建打包目录

    mkdir -p /data/soft/huluer/{src,python3.6,nginx,redis,uwsgi,celery,backend,frontend}
  • 创建huluer用户

    getent group huluer > /dev/null || groupadd -r huluer
    getent passwd huluer > /dev/null || useradd -r -d /data/soft/huluer -g huluer -s /sbin/nologin huluer
  • 上传前端代码到/data/soft/huluer/frontend目录

  • 上传后端代码到/data/soft/huluer/backend目录

配置 python3.6

  • 安装依赖软件

    yum install -y gcc-c++ valgrind-devel systemtap-sdt-devel \
    bzip2-devel ncurses-devel gdbm-devel sqlite-devel openssl-devel \
    readline-devel zlib-devel xz-devel tk-devel wget
  • 下载 python3.6 源码并解压

    wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz -P /data/soft/huluer/src/
    cd /data/soft/huluer/src/
    tar xvf Python-3.6.8.tgz
    cd Python-3.6.8
  • 编译并安装

    ./configure --prefix=/data/soft/huluer/python3.6 \
      --enable-ipv6 \
      --with-computed-gotos=yes \
      --with-dbmliborder=gdbm:ndbm:bdb \
      --with-system-expat \
      --with-system-ffi \
      --enable-loadable-sqlite-extensions \
      --with-dtrace \
      --with-valgrind \
      --with-ensurepip \
      --enable-optimizations
    
      make && make install
  • 验证

    /data/soft/huluer/python3.6/bin/python3.6 -V
    /data/soft/huluer/python3.6/bin/pip3.6 -V
  • 安装葫芦儿 pip 依赖包

    /data/soft/huluer/python3.6/bin/pip3.6 install -r /data/soft/huluer/backend/requirements.txt

配置 nginx

  • 安装依赖

    yum install -y gcc-c++ gperftools-devel openssl-devel pcre-devel zlib-devel GeoIP-devel gd-devel perl-devel perl-ExtUtils-Embed libxslt-devel wget
  • 下载源码包并解压

    wget https://nginx.org/download/nginx-1.12.2.tar.gz -P /data/soft/huluer/src/
    cd /data/soft/huluer/src/
    tar xvf nginx-1.12.2.tar.gz
    cd nginx-1.12.2
  • 编译并安装

    ./configure \
    --prefix=/data/soft/huluer/nginx \
    --user=huluer \
    --group=huluer \
    --with-file-aio \
    --with-http_auth_request_module \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_xslt_module=dynamic \
    --with-http_image_filter_module=dynamic \
    --with-http_geoip_module=dynamic \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_degradation_module \
    --with-http_slice_module \
    --with-http_stub_status_module \
    --with-http_perl_module=dynamic \
    --with-mail=dynamic \
    --with-mail_ssl_module \
    --with-pcre \
    --with-pcre-jit \
    --with-stream=dynamic \
    --with-stream_ssl_module \
    --with-google_perftools_module \
    --with-debug \
    --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \
    --with-ld-opt='-Wl,-z,relro -Wl,-E'
    
    make && make install
  • 创建huluer-nginx.service文件

    echo '
    [Unit]
    Description=HuLuEr Nginx
    After=network.target remote-fs.target nss-lookup.target
    
    [Service]
    Type=forking
    PIDFile=/data/soft/huluer/nginx/logs/nginx.pid
    ExecStartPre=/usr/bin/rm -f /data/soft/huluer/nginx/logs/nginx.pid
    ExecStartPre=/data/soft/huluer/nginx/sbin/nginx -t -c /data/soft/huluer/nginx/conf/nginx.conf
    ExecStart=/data/soft/huluer/nginx/sbin/nginx
    ExecReload=/bin/kill -s HUP $MAINPID
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=mixed
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    ' > /data/soft/huluer/nginx/huluer-nginx.service
  • 注册系统服务

    sh -c 'cp -f /data/soft/huluer/nginx/huluer-nginx.service /usr/lib/systemd/system/huluer-nginx.service'
    systemctl daemon-reload
  • 配置nginx.conf文件

    echo '
    user huluer;
    worker_processes auto;
    error_log /data/soft/huluer/nginx/logs/error.log;
    pid /data/soft/huluer/nginx/logs/nginx.pid;
    
    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  /data/soft/huluer/nginx/logs/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /data/soft/huluer/nginx/conf/mime.types;
        default_type        application/octet-stream;
    
        server {
            listen       80;
            server_name  controller;
    
            access_log /data/soft/huluer/nginx/logs/huluer-frontend-access.log  main;
        	error_log /data/soft/huluer/nginx/logs/huluer-frontend-error.log;
    
            location / {
                 alias /data/soft/huluer/frontend/;
            }
        }
    
        server {
             listen 7777;
             server_name controller;
    
            access_log /data/soft/huluer/nginx/logs/huluer-backend-access.log  main;
        	error_log /data/soft/huluer/nginx/logs/huluer-backend-error.log;
    
             location / {
                 include uwsgi_params;
                 uwsgi_pass 127.0.0.1:7776;
             }
        }
    }
    
    ' > /data/soft/huluer/nginx/conf/nginx.conf

配置 redis

  • 下载源码

    wget http://download.redis.io/releases/redis-5.0.5.tar.gz -P /data/soft/huluer/src/
    cd /data/soft/huluer/src/
    tar xvf redis-5.0.5.tar.gz
    cd redis-5.0.5
  • 编译安装

    make MALLOC=jemalloc PREFIX=/data/soft/huluer/redis all
    make MALLOC=jemalloc PREFIX=/data/soft/huluer/redis install
  • 修改配置文件

    sh -c 'cp -f /data/soft/huluer/src/redis-5.0.5/redis.conf /data/soft/huluer/redis/redis.conf'
    sed -i 's/^pidfile .*/pidfile \/data\/soft\/huluer\/redis\/redis\.pid/g' /data/soft/huluer/redis/redis.conf
    sed -i 's/^logfile .*/logfile \/data\/soft\/huluer\/redis\/redis\.log/g' /data/soft/huluer/redis/redis.conf
    sed -i 's/^dir .*/dir \/data\/soft\/huluer\/redis/g' /data/soft/huluer/redis/redis.conf
  • 创建/data/soft/huluer/redis/bin/redis-shutdown脚本,内容如下

    #!/bin/bash
    #
    # Wrapper to close properly redis and sentinel
    test x"$REDIS_DEBUG" != x && set -x
    
    REDIS_CLI=/data/soft/huluer/redis/bin/redis-cli
    
    # Retrieve service name
    SERVICE_NAME="$1"
    if [ -z "$SERVICE_NAME" ]; then
       SERVICE_NAME=redis
    fi
    
    # Get the proper config file based on service name
    CONFIG_FILE="/data/soft/huluer/redis/$SERVICE_NAME.conf"
    
    # Use awk to retrieve host, port from config file
    HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE | tail -n1`
    PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE | tail -n1`
    PASS=`awk '/^[[:blank:]]*requirepass/ { print $2 }' $CONFIG_FILE | tail -n1`
    SOCK=`awk '/^[[:blank:]]*unixsocket\s/ { print $2 }' $CONFIG_FILE | tail -n1`
    
    # Just in case, use default host, port
    HOST=${HOST:-127.0.0.1}
    if [ "$SERVICE_NAME" = redis ]; then
        PORT=${PORT:-6379}
    else
        PORT=${PORT:-26739}
    fi
    
    # Setup additional parameters
    # e.g password-protected redis instances
    [ -z "$PASS"  ] || ADDITIONAL_PARAMS="-a $PASS"
    
    # shutdown the service properly
    if [ -e "$SOCK" ] ; then
    	$REDIS_CLI -s $SOCK $ADDITIONAL_PARAMS shutdown
    else
    	$REDIS_CLI -h $HOST -p $PORT $ADDITIONAL_PARAMS shutdown
    fi
  • 设置权限

    chmod +x /data/soft/huluer/redis/bin/redis-shutdown
  • 创建huluer-redis.service文件

    echo '
    [Unit]
    Description=Redis persistent key-value database
    After=network.target
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    ExecStart=/data/soft/huluer/redis/bin/redis-server /data/soft/huluer/redis/redis.conf --supervised systemd
    ExecStop=/data/soft/huluer/redis/bin/redis-shutdown
    Type=notify
    User=huluer
    Group=huluer
    RuntimeDirectory=huluer
    RuntimeDirectoryMode=0755
    
    [Install]
    WantedBy=multi-user.target
    
    ' > /data/soft/huluer/redis/huluer-redis.service
  • 注册系统服务

    sh -c 'cp -f /data/soft/huluer/redis/huluer-redis.service /usr/lib/systemd/system/huluer-redis.service'
    systemctl daemon-reload

配置 celery

  • 创建huluer-celery.srvice文件

    echo '
    [Unit]
    Description=HuLuEr Celery Service
    After=network.target
    
    [Service]
    Type=simple
    PIDFile=/data/soft/huluer/celery/celery.pid
    ExecStartPre=/usr/bin/rm -f /data/soft/huluer/celery/celery.pid
    ExecStart=/data/soft/huluer/python3.6/bin/python3.6 /data/soft/huluer/python3.6/bin/celery worker --gid huluer --uid huluer --workdir /data/soft/huluer/backend --app celery_tasks.main --pool solo --pidfile /data/soft/huluer/celery/celery.pid --loglevel info --logfile /data/soft/huluer/celery/celery.log
    ExecReload=/bin/kill -HUP $MAINPID
    KillSignal=SIGQUIT
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    ' > /data/soft/huluer/celery/huluer-celery.service
  • 注册为系统服务

    sh -c 'cp -f /data/soft/huluer/celery/huluer-celery.service /usr/lib/systemd/system/huluer-celery.service'
    systemctl daemon-reload

配置 uwsgi

  • 安装uWSGI

    /data/soft/huluer/python3.6/bin/pip3.6 install uWSGI==2.0.18
  • 创建huluer.ini文件

    echo '
    [uwsgi]
    uid = huluer
    gid = huluer
    pidfile = /data/soft/huluer/uwsgi/uwsgi.pid
    stats = /data/soft/huluer/uwsgi/stats.sock
    socket = 127.0.0.1:7776
    chdir = /data/soft/huluer/backend/
    wsgi-file = myhorizon/wsgi.py
    processes = 4
    threads = 2
    virtualenv=/data/soft/huluer/python3.6
    daemonize = /data/soft/huluer/uwsgi/uwsgi.log
    
    ' > /data/soft/huluer/uwsgi/huluer.ini
  • 创建huluer-uwsgi.service文件

    echo '
    [Unit]
    Description=HuLuEr uWSGI Service
    After=syslog.target
    
    [Service]
    Type=forking
    PIDFile=/data/soft/huluer/uwsgi/uwsgi.pid
    ExecStart=/data/soft/huluer/python3.6/bin/uwsgi --ini /data/soft/huluer/uwsgi/huluer.ini
    ExecReload=/bin/kill -HUP $MAINPID
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=mixed
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    ' > /data/soft/huluer/uwsgi/huluer-uwsgi.service
  • 注册系统服务

    sh -c 'cp -f /data/soft/huluer/uwsgi/huluer-uwsgi.service /usr/lib/systemd/system/huluer-uwsgi.service'
    systemctl daemon-reload

打包

  • 创建安装脚本

    echo '
    #!/bin/bash
    set -e
    echo '关闭SELinux'
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
    echo '创建葫芦儿用户'
    getent group huluer > /dev/null || groupadd -r huluer
    getent passwd huluer > /dev/null || useradd -r -d /data/soft/huluer -g huluer -s /sbin/nologin huluer
    echo '修改部署目录所有者'
    chown -R huluer:huluer /data/soft/huluer
    echo '安装依赖包'
    yum install -y gcc-c++ valgrind-devel systemtap-sdt-devel \
    bzip2-devel ncurses-devel gdbm-devel sqlite-devel \
    openssl-devel readline-devel zlib-devel xz-devel tk-devel \
    gperftools-devel openssl-devel pcre-devel zlib-devel \
    GeoIP-devel gd-devel perl-devel perl-ExtUtils-Embed libxslt-devel
    echo '注册为系统服务'
    cp -f /data/soft/huluer/nginx/huluer-nginx.service /usr/lib/systemd/system/huluer-nginx.service
    cp -f /data/soft/huluer/redis/huluer-redis.service /usr/lib/systemd/system/huluer-redis.service
    cp -f /data/soft/huluer/celery/huluer-celery.service /usr/lib/systemd/system/huluer-celery.service
    cp -f /data/soft/huluer/uwsgi/huluer-uwsgi.service /usr/lib/systemd/system/huluer-uwsgi.service
    systemctl daemon-reload
    echo '防火墙放行'
    firewall-cmd --add-port=80/tcp --add-port=7777/tcp
    firewall-cmd --add-port=80/tcp --add-port=7777/tcp --permanent
    
    ' > /data/soft/huluer/install.sh
    
    chmod +x /data/soft/huluer/install.sh
  • 压缩

    cd /data/soft/
    tar czvf huluer.tar.gz huluer/{python3.6,nginx,redis,uwsgi,celery,backend,frontend,install.sh}
上一页CentOS7.3 编译安装 Python3.6下一页CentOS7 安装 Tomcat8

最后更新于3年前