安装 NodeJS 1 2 3 4 5 6 7 8 9 10 wget https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz tar -xf node-v12.14.1-linux-x64.tar.xz -C /usr/local / chown -R root:root /usr/local /node-v12.14.1-linux-x64 export PATH=/usr/local /node-v12.14.1-linux-x64/bin:$PATH node --version
安装 MongoDB 1 2 3 4 5 6 7 8 9 10 cat <<EOF > /etc/yum.repos.d/mongo.repo [mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever /mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc EOF yum install -y mongodb-org
配置 /etc/mongod.conf
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log storage: dbPath: /var/lib/mongo journal: enabled: true processManagement: fork: true pidFilePath: /var/run/mongodb/mongod.pid timeZoneInfo: /usr/share/zoneinfo net: port: 27017 bindIp: 127.0 .0 .1
启动 mongod
1 2 systemctl enable mongod systemctl start mongod
安装 yapi-cli 1 2 3 4 5 6 npm --registry https://registry.npm.taobao.org install express cd /usr/local /node-v12.14.1-linux-x64/my-yapi/node vendors/server/app.js
配置 supervisor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 pip install supervisor echo_supervisord_conf > /etc/supervisord.conf
配置 /etc/supervisord.d/yapi.ini
:
1 2 3 4 5 6 7 8 9 [program:yapi] command =/usr/local/node-v10.15.3 -linux-x64/bin/node vendors/server/app.jsdirectory =/usr/local/node-v10.15.3 -linux-x64/my-yapiuser =rootstartsecs =3 redirect_stderr =true stdout_logfile_maxbytes =50 MBstdout_logfile_backups =3 stdout_logfile =/var/log/yapi.log
supervisor启动yapi
1 2 3 4 5 systemctl enable supervisord.service supervisord -c /etc/supervisord.conf supervisorctl restart yapi
配置 NginX 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 upstream yapi443 { server 127.0.0.1:3000; } server { listen 443 ssl; server_name yapi.keep.com; root html; index index.html index.htm; ssl_certificate /etc/letsencrypt/live/keep.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/keep.com/privkey.pem; access_log /var/log/nginx/yapi.keep.com.443.access.log main; error_log /var/log/nginx/yapi.keep.com.443.error.log ; location / { proxy_pass http://yapi443; 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_redirect http://$host http://$host:$server_port; add_header Strict-Transport-Security "max-age=31536000"; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }