Skip to content

云主机初始化

必备软件安装

  • java

如果需要包含开发工具。可以安装下面这个,例如 arthas 使用需要用到 jps。

bash
yum install -y java-1.8.0-openjdk-devel.x86_64

否则安装这个

bash
yum install -y java-1.8.0-openjdk.x86_64
  • nginx

安装 nginx

bash
yum install nginx

设定开机自动开启并启动 nginx

bash
systemctl enable nginx
systemctl start nginx

conf 文件的编辑。默认 nginx 安装完后,目录在 etc/nginx 下。

bash
cd /etc/nginx/conf.d
vi xxx.conf

新建一个配置文件,内容如下:

bash
server { 
    listen       443 ssl;
    server_name 写上你的域名;

    location /admin {
        proxy_ignore_client_abort on;
        proxy_pass http://localhost:11090/admin;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header EncryptedFlag false;
    }

    location /devmall/admin {
        proxy_ignore_client_abort on;
        proxy_pass    http://localhost:11010/admin;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header EncryptedFlag false;
    }

    location /uatmall/admin {
        proxy_ignore_client_abort on;
        proxy_pass    http://localhost:11091/admin;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header EncryptedFlag false;
    }

    location /devweb {
            alias /var/workspace/admin-ui-dev/dist;
            index index.html index.htm;
    }

    location /uatweb {
            alias /var/workspace/admin-ui-uat/dist;
            index index.html index.htm;
    }

    location / {
            root /var/workspace/admin-ui-build/dist;
            index index.html index.htm;
    }

    ssl_certificate "/etc/nginx/ssl/8869932__rtm2.cn.pem";
    ssl_certificate_key "/etc/nginx/ssl/8869932__rtm2.cn.key";
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
  }

  # 80 重定向到 443 
  server {
    listen       80;
    server_name  你的域名;
    rewrite ^(.*)$ https://$host$1 permanent;
  }

根据实际情况来调整里面的路径、端口、域名。最后执行验证并重启

bash
nginx -t
nginx -s reload
  • 防火墙

开启防火墙

bash
systemctl start firewalld

开启 80,443 端口,永久生效

bash
firewall-cmd --zone=public --add-port=80/tcp --permanent   
firewall-cmd --zone=public --add-port=443/tcp --permanent

重启防火墙

bash
firewall-cmd --reload

可选软件安装

  • 使用 jenkins 发布

    参阅后端持续集成 jenkins 部署手册 发布及常见问题节点。

  • unzip

    如果需要使用 jenkins 发布,则需要安装 unzip,否则不需要。

bash
yum install unzip