#!/bin/bash
Set variables
APP_NAME=“sky_take_out” APP_GIT_URL=”https://gitee.com/wjqqjw/sky_take_out.git” APP_DIR=“/var/www/\({APP_NAME}" NGINX_CONF_FILE="/etc/nginx/sites-available/\){APP_NAME}.conf” NGINX_SYMLINK_FILE=“/etc/nginx/sites-enabled/${APP_NAME}.conf”
echo “Starting deployment process for ${APP_NAME}”
Install git and nginx
sudo yum update -y sudo yum install git nginx -y
Clone the repository
sudo mkdir -p \({APP_DIR} cd \){APP_DIR} sudo git clone ${APP_GIT_URL} .
Install dependencies
sudo npm install
Build the project
sudo npm run build
Create Nginx configuration file
sudo tee ${NGINX_CONF_FILE} > /dev/null < }
EOF sudo ln -s \({NGINX_CONF_FILE} \){NGINX_SYMLINK_FILE} sudo systemctl restart nginx echo “Deployment process for ${APP_NAME} completed successfully!”listen 80;
server_name localhost;
root ${APP_DIR}/build;
index index.html;
location / {
try_files \$uri /index.html;
}
Create symlink to enable site in Nginx
Restart Nginx service