Bootstrap

vue 自动化构建 部署 sh脚本构建 linux环境 nginx 服务器

好记性不如烂笔头 整理记录自用之

目录

  • 安装 nginx
  • nginx.conf 配置文件
  • nginx.config vue 配置
  • nginx.config 二级域名代理其他node程序配置
  • 自动构建 sh脚本

linux 环境安装 nginx

  1. epel-release 安装

    sudo yum install epel-release
    
  2. nginx 安装

    sudo yum install nginx
    
  3. nginx 验证 或者 直接访问80端口

    ps -ef | grep nginx
    
  常用命令
    nginx -v         #查看版本
	nginx            #启动命令
	nginx -s stop    #停止
	nginx -t         #修改完nginx.conf后检查语法是否正确
	nginx -s reload  #重启(修改完配置文件可以使用此命令重新加载配置文件)

nginx.conf 配置

常规安装 nginx配置文件位置为 /etc/nginx/nginx.conf
编辑配置文件:
1.  直接 编辑方式
    vim /etc/nginx/nginx.conf
2.  本地编辑  `cd /etc/nginx/`
    sz 下载至本地  `sz nginx.conf`
    本地编辑 
    线上删除 `rm nginx.conf`
    上传线上 `rz `

nginx.config vue 配置

server {
        listen 80;
        server_name vuetest.feq***.com;
        root /home/vue_eslint/dist;
        location / {
            try_files $uri $uri/ /index.html;
        }
    }

nginx.config 二级域名代理其他node程序配置

server {
        listen 80;
        server_name didi.feq***.com;
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:3399;
        }
    }

    server {
        listen 80;
        server_name linlin.feq***.com;
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:8869;
        }
    }

sh脚本 自动构建 vue_test_build.sh


// sh 文件内容
// vue_test_build.sh

cd /home

rm -rf ./vue_test

git clone https://gitee.com/feq***/vue_test.git

cd /home/vue_test

npm install

rm -rf /home/vue_test/dist

npm run build
// 运行执行构建 vue_test_build.sh

sh /home/sh/vue_test_build.sh