|
@@ -1,8 +1,7 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
-SERVER_IP="47.253.147.187"
|
|
|
|
|
|
|
+SERVER_IP="45.61.60.10"
|
|
|
SERVER_USER="root"
|
|
SERVER_USER="root"
|
|
|
-SERVER_PASS="5H0FuZ:2s0q)Lx"
|
|
|
|
|
-NODE_BIN="/www/server/nodejs/v22.16.0/bin"
|
|
|
|
|
|
|
+SERVER_PASS="UQb9TgSwC@vwhEM"
|
|
|
|
|
|
|
|
/usr/bin/expect <<EOF
|
|
/usr/bin/expect <<EOF
|
|
|
set timeout 180
|
|
set timeout 180
|
|
@@ -15,19 +14,17 @@ expect {
|
|
|
|
|
|
|
|
expect "#"
|
|
expect "#"
|
|
|
|
|
|
|
|
-# 1. Link Node binaries
|
|
|
|
|
-send "echo '--- LINKING NODE BINARIES ---'\r"
|
|
|
|
|
-send "ln -sf $NODE_BIN/node /usr/bin/node\r"
|
|
|
|
|
-send "ln -sf $NODE_BIN/npm /usr/bin/npm\r"
|
|
|
|
|
-send "ln -sf $NODE_BIN/npx /usr/bin/npx\r"
|
|
|
|
|
|
|
+# 1. Check Node binaries
|
|
|
|
|
+send "echo '--- CHECKING NODE BINARIES ---'\r"
|
|
|
|
|
+send "which node\r"
|
|
|
|
|
+send "which npm\r"
|
|
|
|
|
+send "which npx\r"
|
|
|
|
|
|
|
|
# 2. Finish backend deployment
|
|
# 2. Finish backend deployment
|
|
|
send "echo '--- FINISHING BACKEND DEPLOYMENT ---'\r"
|
|
send "echo '--- FINISHING BACKEND DEPLOYMENT ---'\r"
|
|
|
-send "cd /www/wwwroot/ccdw-website/server\r"
|
|
|
|
|
|
|
+send "cd /var/www/ccdw-website/server\r"
|
|
|
send "npm install --omit=dev --registry=https://registry.npmmirror.com\r"
|
|
send "npm install --omit=dev --registry=https://registry.npmmirror.com\r"
|
|
|
send "npm install -g pm2 --registry=https://registry.npmmirror.com\r"
|
|
send "npm install -g pm2 --registry=https://registry.npmmirror.com\r"
|
|
|
-# Link PM2
|
|
|
|
|
-send "ln -sf $NODE_BIN/pm2 /usr/bin/pm2\r"
|
|
|
|
|
|
|
|
|
|
# Start App
|
|
# Start App
|
|
|
send "echo '--- STARTING APP ---'\r"
|
|
send "echo '--- STARTING APP ---'\r"
|
|
@@ -37,13 +34,13 @@ send "pm2 save\r"
|
|
|
|
|
|
|
|
# 3. Create Nginx Config (HTTP)
|
|
# 3. Create Nginx Config (HTTP)
|
|
|
send "echo '--- CREATING NGINX CONFIG ---'\r"
|
|
send "echo '--- CREATING NGINX CONFIG ---'\r"
|
|
|
-send "cat > /www/server/panel/vhost/nginx/ccdw.xyz.conf <<ENDCONF
|
|
|
|
|
|
|
+send "cat > /etc/nginx/sites-available/ccdw.xyz.conf <<ENDCONF
|
|
|
server {
|
|
server {
|
|
|
listen 80;
|
|
listen 80;
|
|
|
server_name ccdw.xyz www.ccdw.xyz;
|
|
server_name ccdw.xyz www.ccdw.xyz;
|
|
|
|
|
|
|
|
- access_log /www/wwwlogs/ccdw.xyz.log;
|
|
|
|
|
- error_log /www/wwwlogs/ccdw.xyz.error.log;
|
|
|
|
|
|
|
+ access_log /var/log/nginx/ccdw.xyz.log;
|
|
|
|
|
+ error_log /var/log/nginx/ccdw.xyz.error.log;
|
|
|
|
|
|
|
|
location / {
|
|
location / {
|
|
|
proxy_pass http://127.0.0.1:3001;
|
|
proxy_pass http://127.0.0.1:3001;
|
|
@@ -58,8 +55,8 @@ ENDCONF\r"
|
|
|
# 4. Reload Nginx
|
|
# 4. Reload Nginx
|
|
|
send "echo '--- RELOADING NGINX ---'\r"
|
|
send "echo '--- RELOADING NGINX ---'\r"
|
|
|
send "nginx -t\r"
|
|
send "nginx -t\r"
|
|
|
-# 宝塔环境下 reload 命令
|
|
|
|
|
-send "/etc/init.d/nginx reload\r"
|
|
|
|
|
|
|
+send "ln -sf /etc/nginx/sites-available/ccdw.xyz.conf /etc/nginx/sites-enabled/ccdw.xyz.conf\r"
|
|
|
|
|
+send "systemctl reload nginx\r"
|
|
|
|
|
|
|
|
# 5. Check URL access
|
|
# 5. Check URL access
|
|
|
send "echo '--- CHECKING ACCESS ---'\r"
|
|
send "echo '--- CHECKING ACCESS ---'\r"
|