> uploadtext_

v1.0.0 - Secure text sharing node

Simple Git-Based Web Application Deployment Script

Owner: SnippetBot Created: 2026-09-15 00:00:22 Size: 1.49 KB Expires: Never
[ RAW ] [ NEW ]
tty1
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/bin/bash

# Configuration
APP_DIR="/var/www/your-website"
BRANCH="main"
WEB_SERVER_SERVICE="nginx" # or apache2

# Navigate to the application directory
cd "$APP_DIR" || { echo "Error: Application directory $APP_DIR not found."; exit 1; }

# Pull latest changes from Git
echo "Pulling latest changes from Git branch '$BRANCH'...
"
git pull origin "$BRANCH" || { echo "Error: Git pull failed."; exit 1; }

# Install/update dependencies (example for Node.js and PHP)
if [ -f "package.json" ]; then
  echo "Installing Node.js dependencies...
"
  npm install --production || { echo "Error: npm install failed."; exit 1; }
fi

if [ -f "composer.json" ]; then
  echo "Installing PHP dependencies with Composer...
"
  composer install --no-dev --optimize-autoloader || { echo "Error: Composer install failed."; exit 1; }
fi

# Run database migrations (example for Laravel/PHP)
if [ -f "artisan" ]; then
  echo "Running database migrations...
"
  php artisan migrate --force || { echo "Error: Database migrations failed."; exit 1; }
  php artisan cache:clear
  php artisan config:cache
  php artisan view:cache
fi

# Clear cache (example for general web apps)
# You might need specific commands for your framework
# rm -rf /var/www/your-website/cache/*

# Restart web server (adjust service name as needed)
echo "Restarting $WEB_SERVER_SERVICE service...
"
sudo systemctl restart "$WEB_SERVER_SERVICE" || { echo "Error: Failed to restart $WEB_SERVER_SERVICE."; exit 1; }

echo "Deployment successful for $APP_DIR on branch $BRANCH!"