# vote **Repository Path**: lgc653/vote ## Basic Information - **Project Name**: vote - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-09 - **Last Updated**: 2024-10-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 视频投票 ## 安装环境 ```sh # 安装mysql客户端 wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm sudo yum -y install mysql57-community-release-el7-10.noarch.rpm sudo yum -y install mysql-community-client # 安装最新版本的nodejs,使用12.x版本保证兼容性 curl –silent –location https://rpm.nodesource.com/setup_12.x | sudo bash - sudo yum -y install nodejs npm config set registry "https://registry.npm.taobao.org" # 也可以通过N来安装 npm install -g n n 12.18.1 n lts # 安装git curl https://setup.ius.io | sudo sh sudo yum remove -y git | sudo yum -y install git2u ``` ## 安装项目 ```sh # clone代码 git config --global credential.helper store cd /dtc && git clone http://git.uue.cn:9999/lgc653/vote # 更新代码 cd /dtc/vote && git reset --hard origin/master && git pull # 安装module cd /dtc/vote/admin && npm install --registry=https://registry.npm.taobao.org cd /dtc/vote/home && npm install --registry=https://registry.npm.taobao.org cd /dtc/vote/service && npm install --registry=https://registry.npm.taobao.org # 将/dtc/vote/static作为NGINX的root mkdir -p /dtc/vote/static_admin mkdir -p /dtc/vote/static_home mkdir -p /dtc/vote/static # 编译admin,拷贝到static_admin cd /dtc/vote/admin && npm run build && rm -rf ../static_admin/* && \cp dist/* ../static_admin -rf # 编译home,拷贝到static_home cd /dtc/vote/home && npm run build && rm -rf ../static_home/* && \cp dist/* ../static_home -rf # 拷贝home,admin结果到static cd /dtc/vote/ && rm -rf ./static/* && \cp /dtc/vote/static_home/* ./static -rf && \cp /dtc/vote/static_admin/* ./static -rf # 创建导入数据库(略……) mysql -uroot -pxxxxx -e "create database vote default character set utf8mb4 collate utf8mb4_unicode_ci;" # 编辑env.json文件 vi /dtc/vote/service/config/env.json # 创建上传目录 mkdir -p /dtc/vote/service/public/uploads/ # 安装pm2 npm install pm2 -g --registry=https://registry.npm.taobao.org # 启动service端,不要加 --watch,否则上传文件到service的upload会重启服务 cd /dtc/vote/service && pm2 start ./bin/www --name="vote" # 启动定时任务 cd /dtc/vote/service && pm2 start ./bin/cron.js --name="vote-cron" # 更新service端 pm2 restart vote pm2 restart vote-cron # 重启nginx /usr/local/nginx/sbin/nginx -s reload ``` 编辑 env.json 文件 ```sh { "password": { "secret": "0xJlDh" }, "jwt": { "secret": "superSecret" }, "sequelize": { "database": "vote", "username": "root", "password": "", "host": "127.0.0.1", "dialect": "mysql" } } ``` vote_uue_cn.conf ```nginx upstream vote { server 127.0.0.1:34568; } server { listen 80; listen 443 ssl; server_name vote.uue.cn; location / { root /dtc/vote/static; index index.html index.htm; try_files $uri $uri/ /index.html; } location = /index.html { root /dtc/vote/static; expires -1; } location ^~ /api/ { proxy_pass http://vote; proxy_redirect off; 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_send_timeout 600; proxy_read_timeout 600; proxy_connect_timeout 600; keepalive_timeout 600; } access_log off; error_log off; server_name_in_redirect off; } ``` ## 更新项目 ```sh # 更新代码 cd /dtc/vote && git reset --hard origin/master && git pull cd /dtc/vote/admin && npm run build && rm -rf ../static_admin/* && \cp dist/* ../static_admin -rf cd /dtc/vote/home && npm run build && rm -rf ../static_home/* && \cp dist/* ../static_home -rf cd /dtc/vote/ && rm -rf ./static/* && \cp /dtc/vote/static_home/* ./static -rf && \cp /dtc/vote/static_admin/* ./static -rf pm2 restart vote pm2 restart vote-cron ``` ## 超级用户 * user:228228 * pass:225225225