GT 前端部署

From GoToken's Wiki!
Jump to navigation Jump to search

安装

nginx

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04 sudo apt update sudo apt install nginx 有可能需要执行 sudo apt-get update sudo apt-get install nginx

nodejs & npm

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 sudo apt update sudo apt install nodejs sudo apt install npm 执行完 Installing Using a PPA node --version, 确保在 v10 再根据提示安装 yarn

Code

在 leec 用户下

第一次进入 mkdir code cd ~/code git clone [email protected]:gotoken-io/gt-frontend.git cd ~/code/gt-frontend yarn

更新代码

[每次pull 新代码后都执行一下操作] yarn yarn run build

查看当前ip curl -4 icanhazip.com

nginx 配置

服务器需要先对外开放 80 端口

   /etc/nginx/sites-available/default 
   server {
   listen 80;
   # gzip config
   gzip on;
   gzip_min_length 1k;
   gzip_comp_level 9;
   gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
   gzip_vary on;
   gzip_disable "MSIE [1-6]\.";
   # root /usr/share/nginx/html;
   location / {
       # 用于配合 browserHistory使用
       try_files $uri $uri/ /index.html;
       alias /home/leec/code/gt-frontend/dist/;
   }
   location /server {
       proxy_pass http://127.0.0.1:5000/;
       proxy_set_header   X-Forwarded-Proto $scheme;
       proxy_set_header   X-Real-IP         $remote_addr;
   }
   }
   nginx -t

nginx 相关命令

sudo systemctl start nginx sudo systemctl restart nginx