#!/bin/bash set -e echo "==========================================" echo " AtomCMS Deployment Script" echo "==========================================" PROJECT_DIR="/var/www/atomcms" WEB_USER="www-data" cd "$PROJECT_DIR" echo "[1/8] Installing PHP dependencies..." composer install --no-dev --optimize-autoloader --no-interaction echo "[2/8] Installing JS dependencies..." npm install --production=false echo "[3/8] Building frontend assets..." npm run build echo "[4/8] Running database migrations..." php artisan migrate --force echo "[5/8] Clearing all caches..." php artisan optimize:clear echo "[6/8] Caching configuration, routes, and views..." php artisan config:cache php artisan route:cache php artisan view:cache echo "[7/8] Fixing file permissions..." chown -R "$WEB_USER":"$WEB_USER" storage bootstrap/cache public/build chmod -R 775 storage bootstrap/cache public/build echo "[8/8] Clearing OPcache..." php -r "if (function_exists('opcache_reset')) { opcache_reset(); echo 'OPcache cleared'.PHP_EOL; } else { echo 'OPcache not enabled'.PHP_EOL; }" echo "==========================================" echo " Deployment complete!" echo "=========================================="