Practical examples and usage scenarios for PUQcloud installation and management scripts.
For a completely new server:
#!/bin/bash
# Fresh installation script
# Download all scripts
wget https://raw.githubusercontent.com/puqcloud/PUQcloud-Scripts/main/Debian_Ubuntu/install.sh
wget https://raw.githubusercontent.com/puqcloud/PUQcloud-Scripts/main/Debian_Ubuntu/phpmyadmin.sh
wget https://raw.githubusercontent.com/puqcloud/PUQcloud-Scripts/main/Debian_Ubuntu/delete_and_clear_databases.sh
# Make executable
chmod +x *.sh
# Install PUQcloud
sudo ./install.sh example.com admin@example.com SecurePass123 "John Admin"
# Install phpMyAdmin (optional)
sudo ./phpmyadmin.sh
echo "β
Fresh installation completed!"
echo "π Web interface: https://example.com"
echo "ποΈ phpMyAdmin: https://phpmyadmin.example.com"Update PUQcloud to the latest version:
#!/bin/bash
# Update script
echo "π Starting PUQcloud update..."
# Run update
sudo ./install.sh
# Choose "update" when prompted
echo "β
Update completed!"
# Check status
cd /var/www/puqcloud
php artisan --version
php artisan horizon:statusFull cleanup and reinstallation:
#!/bin/bash
# Complete reset script
echo "β οΈ WARNING: This will delete ALL databases!"
read -p "Continue? Type 'YES' to confirm: " confirm
if [ "$confirm" = "YES" ]; then
echo "π§Ή Cleaning databases..."
sudo ./delete_and_clear_databases.sh
echo "π Installing PUQcloud..."
sudo ./install.sh production.example.com admin@example.com NewPass123 "System Admin"
echo "ποΈ Installing phpMyAdmin..."
sudo ./phpmyadmin.sh
echo "β
Complete reset finished!"
else
echo "β Operation cancelled"
fiEnterprise-grade installation with monitoring:
#!/bin/bash
# Production deployment script
LOG_FILE="/var/log/puqcloud_deployment_$(date +%Y%m%d_%H%M%S).log"
DOMAIN="app.company.com"
ADMIN_EMAIL="admin@company.com"
ADMIN_PASS="$(openssl rand -base64 32)"
ADMIN_NAME="System Administrator"
{
echo "=== PUQcloud Production Deployment ==="
echo "Started: $(date)"
echo "Domain: $DOMAIN"
echo "Admin Email: $ADMIN_EMAIL"
echo "Generated Password: $ADMIN_PASS"
echo ""
# Update system
echo "π¦ Updating system packages..."
apt update && apt upgrade -y
# Install PUQcloud
echo "π Installing PUQcloud..."
./install.sh "$DOMAIN" "$ADMIN_EMAIL" "$ADMIN_PASS" "$ADMIN_NAME"
# Install phpMyAdmin
echo "ποΈ Installing phpMyAdmin..."
./phpmyadmin.sh
# Security hardening
echo "π Applying security settings..."
# Disable password authentication for SSH
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl restart sshd
# Configure firewall
ufw --force enable
ufw allow ssh
ufw allow http
ufw allow https
# Set up monitoring
echo "π Setting up monitoring..."
# Install log rotation
cat > /etc/logrotate.d/puqcloud << 'EOF'
/var/www/puqcloud/storage/logs/*.log {
daily
missingok
rotate 30
compress
notifempty
create 644 www-data www-data
}
EOF
echo "β
Production deployment completed!"
echo "Admin password: $ADMIN_PASS"
} 2>&1 | tee "$LOG_FILE"
echo ""
echo "π Deployment log saved to: $LOG_FILE"
echo "π IMPORTANT: Save the admin password securely!"Deploy PUQcloud on multiple servers:
#!/bin/bash
# Multi-server deployment script
SERVERS=(
"server1.example.com:app1.example.com"
"server2.example.com:app2.example.com"
"server3.example.com:app3.example.com"
)
ADMIN_EMAIL="admin@example.com"
ADMIN_NAME="Multi-Server Admin"
for server_config in "${SERVERS[@]}"; do
IFS=':' read -r server_ip domain <<< "$server_config"
echo "π Deploying to $server_ip ($domain)..."
# Generate unique password for each server
password=$(openssl rand -base64 16)
# Copy scripts to server
scp install.sh phpmyadmin.sh root@$server_ip:/tmp/
# Run installation
ssh root@$server_ip << EOF
cd /tmp
chmod +x *.sh
./install.sh "$domain" "$ADMIN_EMAIL" "$password" "$ADMIN_NAME"
./phpmyadmin.sh
EOF
echo "β
$domain deployed successfully"
echo "Password: $password"
echo ""
done
echo "π Multi-server deployment completed!"Quick setup for development:
#!/bin/bash
# Development environment script
DEV_DOMAIN="puqcloud.local"
DEV_EMAIL="dev@localhost"
DEV_PASS="dev123"
DEV_NAME="Developer"
echo "π οΈ Setting up development environment..."
# Add domain to hosts file
echo "127.0.0.1 $DEV_DOMAIN" >> /etc/hosts
echo "127.0.0.1 phpmyadmin.$DEV_DOMAIN" >> /etc/hosts
# Install with development settings
sudo ./install.sh "$DEV_DOMAIN" "$DEV_EMAIL" "$DEV_PASS" "$DEV_NAME"
# Enable debug mode
cd /var/www/puqcloud
sed -i 's/APP_DEBUG=.*/APP_DEBUG=true/' .env
sed -i 's/APP_ENV=.*/APP_ENV=local/' .env
# Install development dependencies
composer install --dev
npm install --dev
# Install phpMyAdmin
sudo ./phpmyadmin.sh
echo "β
Development environment ready!"
echo "π Application: http://$DEV_DOMAIN"
echo "ποΈ phpMyAdmin: http://phpmyadmin.$DEV_DOMAIN"
echo "π Login: $DEV_EMAIL / $DEV_PASS"Reset testing environment daily:
#!/bin/bash
# Daily testing reset script (for cron)
BACKUP_DIR="/backups/puqcloud"
DATE=$(date +%Y%m%d)
TEST_DOMAIN="test.puqcloud.local"
echo "π Daily testing environment reset - $DATE"
# Create backup of current state
mkdir -p "$BACKUP_DIR"
mysqldump --all-databases > "$BACKUP_DIR/test_backup_$DATE.sql"
tar -czf "$BACKUP_DIR/files_backup_$DATE.tar.gz" /var/www/puqcloud
# Reset databases
./delete_and_clear_databases.sh << 'EOF'
root_password
EOF
# Fresh installation
./install.sh "$TEST_DOMAIN" "test@localhost" "test123" "Test Admin"
# Load test data
cd /var/www/puqcloud
php artisan db:seed --class=TestDataSeeder
echo "β
Testing environment reset completed!"
# Clean old backups (keep last 7 days)
find "$BACKUP_DIR" -name "*backup*" -mtime +7 -deleteCreate containerized PUQcloud:
#!/bin/bash
# Docker deployment script
# Create Dockerfile
cat > Dockerfile << 'EOF'
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl wget git sudo \
&& rm -rf /var/lib/apt/lists/*
# Copy scripts
COPY install.sh phpmyadmin.sh /opt/puqcloud/
WORKDIR /opt/puqcloud
# Make scripts executable
RUN chmod +x *.sh
# Install PUQcloud
RUN ./install.sh container.local admin@container.local admin123 "Container Admin"
# Expose ports
EXPOSE 80 443
# Start services
CMD service mysql start && \
service redis-server start && \
service php8.2-fpm start && \
service nginx start && \
service supervisor start && \
tail -f /var/log/nginx/access.log
EOF
# Build and run container
docker build -t puqcloud:latest .
docker run -d -p 8080:80 -p 8443:443 --name puqcloud-container puqcloud:latest
echo "β
PUQcloud container deployed!"
echo "π Access at: http://localhost:8080"Automated deployment via GitHub Actions:
# .github/workflows/deploy.yml
name: Deploy PUQcloud
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to server
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /opt/puqcloud-scripts
git pull origin main
# Run update
sudo ./install.sh
# Check status
cd /var/www/puqcloud
php artisan horizon:status
# Send notification
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"PUQcloud deployment completed successfully!"}' \
${{ secrets.SLACK_WEBHOOK }}Comprehensive testing script:
#!/bin/bash
# Automated testing script
TEST_LOG="/var/log/puqcloud_test_$(date +%Y%m%d_%H%M%S).log"
{
echo "=== PUQcloud Automated Tests ==="
echo "Started: $(date)"
echo ""
# Test 1: Service Status
echo "π Test 1: Service Status"
services=(nginx php8.2-fpm mariadb redis-server supervisor)
for service in "${services[@]}"; do
if systemctl is-active --quiet "$service"; then
echo "β
$service: Running"
else
echo "β $service: Not running"
fi
done
echo ""
# Test 2: Web Response
echo "π Test 2: Web Server Response"
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost)
if [ "$response" = "200" ]; then
echo "β
Web server: Responding (HTTP $response)"
else
echo "β Web server: Not responding (HTTP $response)"
fi
echo ""
# Test 3: Database Connection
echo "π Test 3: Database Connection"
if mysql -e "SELECT 1" &>/dev/null; then
echo "β
Database: Connected"
else
echo "β Database: Connection failed"
fi
echo ""
# Test 4: Laravel Application
echo "π Test 4: Laravel Application"
cd /var/www/puqcloud
if php artisan about &>/dev/null; then
echo "β
Laravel: Application working"
else
echo "β Laravel: Application error"
fi
echo ""
# Test 5: Horizon Status
echo "π Test 5: Horizon Queue System"
horizon_status=$(php artisan horizon:status 2>/dev/null)
if echo "$horizon_status" | grep -q "running"; then
echo "β
Horizon: Running"
else
echo "β Horizon: Not running"
fi
echo ""
# Test 6: SSL Certificate
echo "π Test 6: SSL Certificate"
if [ -f /etc/letsencrypt/live/*/fullchain.pem ]; then
cert_exp=$(openssl x509 -enddate -noout -in /etc/letsencrypt/live/*/fullchain.pem | cut -d= -f2)
echo "β
SSL: Certificate found (expires: $cert_exp)"
else
echo "β οΈ SSL: No Let's Encrypt certificate found"
fi
echo ""
echo "=== Test Summary ==="
echo "Completed: $(date)"
} 2>&1 | tee "$TEST_LOG"
echo "π Test log saved to: $TEST_LOG"
# Send results to monitoring system (optional)
# curl -X POST -H "Content-Type: application/json" \
# -d @"$TEST_LOG" \
# https://monitoring.example.com/api/test-resultsComplete backup solution:
#!/bin/bash
# Automated backup script
BACKUP_DIR="/backups/puqcloud"
DATE=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=30
echo "πΎ Starting PUQcloud backup - $DATE"
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Database backup
echo "π Backing up databases..."
mysqldump --all-databases --single-transaction --routines --triggers > "$BACKUP_DIR/databases_$DATE.sql"
# Files backup
echo "π Backing up files..."
tar -czf "$BACKUP_DIR/files_$DATE.tar.gz" \
/var/www/puqcloud \
/etc/nginx/sites-available \
/etc/php/8.2 \
/etc/letsencrypt
# Configuration backup
echo "βοΈ Backing up configurations..."
{
echo "=== System Information ==="
hostnamectl
echo ""
echo "=== Service Status ==="
systemctl status nginx php8.2-fpm mariadb redis-server supervisor --no-pager
echo ""
echo "=== PUQcloud Version ==="
cd /var/www/puqcloud && php artisan --version
echo ""
echo "=== Installed Packages ==="
dpkg -l | grep -E "(nginx|php|mysql|redis)"
} > "$BACKUP_DIR/system_info_$DATE.txt"
# Compress everything
echo "ποΈ Compressing backup..."
cd "$BACKUP_DIR"
tar -czf "puqcloud_complete_backup_$DATE.tar.gz" \
"databases_$DATE.sql" \
"files_$DATE.tar.gz" \
"system_info_$DATE.txt"
# Remove individual files
rm "databases_$DATE.sql" "files_$DATE.tar.gz" "system_info_$DATE.txt"
# Clean old backups
echo "π§Ή Cleaning old backups..."
find "$BACKUP_DIR" -name "puqcloud_complete_backup_*.tar.gz" -mtime +$RETENTION_DAYS -delete
# Calculate backup size
backup_size=$(du -h "$BACKUP_DIR/puqcloud_complete_backup_$DATE.tar.gz" | cut -f1)
echo "β
Backup completed!"
echo "π¦ Backup file: puqcloud_complete_backup_$DATE.tar.gz"
echo "π Backup size: $backup_size"
# Optional: Upload to cloud storage
# aws s3 cp "$BACKUP_DIR/puqcloud_complete_backup_$DATE.tar.gz" s3://your-backup-bucket/Regular maintenance tasks:
#!/bin/bash
# System maintenance script
echo "π§ Starting PUQcloud maintenance..."
# Update system packages
echo "π¦ Updating system packages..."
apt update && apt upgrade -y
# Clean package cache
apt autoremove -y && apt autoclean
# Optimize database
echo "ποΈ Optimizing databases..."
cd /var/www/puqcloud
php artisan optimize
mysqlcheck --optimize --all-databases
# Clear application cache
echo "π§Ή Clearing application cache..."
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
# Restart services
echo "π Restarting services..."
systemctl restart php8.2-fpm nginx supervisor
# Clean old logs
echo "π Cleaning old logs..."
find /var/log -name "*.log" -mtime +7 -delete
find /var/www/puqcloud/storage/logs -name "*.log" -mtime +7 -delete
# Check disk space
echo "π½ Checking disk space..."
df -h
# Security updates
echo "π Checking security updates..."
unattended-upgrade --dry-run
echo "β
Maintenance completed!"Comprehensive health monitoring:
#!/bin/bash
# Health check script for monitoring
# Configuration
WEBHOOK_URL="https://hooks.slack.com/your/webhook/url"
EMAIL_ALERTS="admin@example.com"
DOMAIN="example.com"
# Check functions
check_service() {
local service=$1
if systemctl is-active --quiet "$service"; then
return 0
else
return 1
fi
}
check_http() {
local url=$1
local expected_code=${2:-200}
local response=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response" = "$expected_code" ]; then
return 0
else
return 1
fi
}
send_alert() {
local message=$1
local level=${2:-warning}
# Send to Slack
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"[$level] PUQcloud Alert: $message\"}" \
"$WEBHOOK_URL"
# Send email
echo "$message" | mail -s "PUQcloud Alert" "$EMAIL_ALERTS"
}
# Health checks
echo "π₯ Running health checks..."
# Check services
critical_services=(nginx php8.2-fpm mariadb redis-server supervisor)
for service in "${critical_services[@]}"; do
if ! check_service "$service"; then
send_alert "$service is not running on $(hostname)" "critical"
fi
done
# Check web response
if ! check_http "https://$DOMAIN"; then
send_alert "Website $DOMAIN is not responding" "critical"
fi
# Check phpMyAdmin
if ! check_http "https://phpmyadmin.$DOMAIN"; then
send_alert "phpMyAdmin is not accessible" "warning"
fi
# Check database connection
if ! mysql -e "SELECT 1" &>/dev/null; then
send_alert "Database connection failed" "critical"
fi
# Check disk space
disk_usage=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ "$disk_usage" -gt 85 ]; then
send_alert "Disk usage is at $disk_usage%" "warning"
fi
# Check memory usage
memory_usage=$(free | grep Mem | awk '{printf("%.2f", $3/$2 * 100.0)}')
if (( $(echo "$memory_usage > 90" | bc -l) )); then
send_alert "Memory usage is at $memory_usage%" "warning"
fi
# Check Horizon
cd /var/www/puqcloud
if ! php artisan horizon:status | grep -q "running"; then
send_alert "Horizon queue system is not running" "critical"
fi
# Check SSL certificate expiry
if [ -f /etc/letsencrypt/live/*/fullchain.pem ]; then
cert_exp_date=$(openssl x509 -enddate -noout -in /etc/letsencrypt/live/*/fullchain.pem | cut -d= -f2)
cert_exp_timestamp=$(date -d "$cert_exp_date" +%s)
current_timestamp=$(date +%s)
days_until_exp=$(( (cert_exp_timestamp - current_timestamp) / 86400 ))
if [ "$days_until_exp" -lt 30 ]; then
send_alert "SSL certificate expires in $days_until_exp days" "warning"
fi
fi
echo "β
Health checks completed!"Set up PUQcloud with external APIs:
#!/bin/bash
# API integration setup
cd /var/www/puqcloud
echo "π Setting up API integrations..."
# Payment gateways
echo "π³ Configuring payment gateways..."
php artisan config:set services.stripe.key "$STRIPE_KEY"
php artisan config:set services.stripe.secret "$STRIPE_SECRET"
php artisan config:set services.paypal.client_id "$PAYPAL_CLIENT_ID"
php artisan config:set services.paypal.secret "$PAYPAL_SECRET"
# Email services
echo "π§ Configuring email services..."
php artisan config:set mail.driver smtp
php artisan config:set mail.host smtp.mailgun.org
php artisan config:set mail.username "$MAILGUN_USERNAME"
php artisan config:set mail.password "$MAILGUN_PASSWORD"
# Cloud storage
echo "βοΈ Configuring cloud storage..."
php artisan config:set filesystems.disks.s3.key "$AWS_ACCESS_KEY"
php artisan config:set filesystems.disks.s3.secret "$AWS_SECRET_KEY"
php artisan config:set filesystems.disks.s3.region "$AWS_REGION"
php artisan config:set filesystems.disks.s3.bucket "$AWS_BUCKET"
# SMS services
echo "π± Configuring SMS services..."
php artisan config:set services.twilio.sid "$TWILIO_SID"
php artisan config:set services.twilio.token "$TWILIO_TOKEN"
# Clear cache
php artisan config:clear
php artisan cache:clear
echo "β
API integrations configured!"Configure multiple domains for PUQcloud:
#!/bin/bash
# Multi-domain setup script
DOMAINS=(
"app.company.com"
"client.company.com"
"partner.company.com"
)
echo "π Setting up multi-domain configuration..."
for domain in "${DOMAINS[@]}"; do
echo "π Configuring $domain..."
# Create Nginx configuration
cat > "/etc/nginx/sites-available/$domain" << EOF
server {
listen 80;
server_name $domain;
root /var/www/puqcloud/public;
index index.php index.html index.htm;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
try_files \$uri /index.php?\$query_string;
expires max;
log_not_found off;
}
}
EOF
# Enable site
ln -sf "/etc/nginx/sites-available/$domain" "/etc/nginx/sites-enabled/"
# Get SSL certificate
certbot --nginx -d "$domain" --non-interactive --agree-tos -m "admin@$domain"
done
# Test configuration
nginx -t && systemctl reload nginx
echo "β
Multi-domain setup completed!"Set up complete development environment:
#!/bin/bash
# Development workflow setup
echo "π Setting up development workflow..."
# Install development tools
echo "π οΈ Installing development tools..."
npm install -g @vue/cli laravel-mix cross-env
# Install VS Code extensions (if VS Code is available)
if command -v code &> /dev/null; then
echo "π Installing VS Code extensions..."
code --install-extension bmewburn.vscode-intelephense-client
code --install-extension bradlc.vscode-tailwindcss
code --install-extension octref.vetur
fi
# Set up Git hooks
echo "π Setting up Git hooks..."
cd /var/www/puqcloud
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
# Pre-commit hook for PUQcloud
echo "π Running pre-commit checks..."
# PHP syntax check
find . -name "*.php" -not -path "./vendor/*" -exec php -l {} \; | grep -v "No syntax errors"
# Run PHPUnit tests
php artisan test
# Check for debugging statements
if grep -r "dd(" app/ resources/ || grep -r "dump(" app/ resources/; then
echo "β Found debugging statements in code!"
exit 1
fi
echo "β
Pre-commit checks passed!"
EOF
chmod +x .git/hooks/pre-commit
# Set up environment switcher
cat > switch-env.sh << 'EOF'
#!/bin/bash
# Environment switcher
ENV=${1:-local}
case $ENV in
"local")
cp .env.local .env
php artisan config:clear
echo "Switched to local environment"
;;
"staging")
cp .env.staging .env
php artisan config:clear
echo "Switched to staging environment"
;;
"production")
cp .env.production .env
php artisan config:clear
echo "Switched to production environment"
;;
*)
echo "Usage: $0 {local|staging|production}"
exit 1
;;
esac
EOF
chmod +x switch-env.sh
echo "β
Development workflow setup completed!"Complete CI/CD pipeline setup:
#!/bin/bash
# Deployment pipeline setup
echo "π Setting up deployment pipeline..."
# Create deployment script
cat > deploy.sh << 'EOF'
#!/bin/bash
# Deployment script
set -e
ENVIRONMENT=${1:-production}
BRANCH=${2:-main}
echo "π Deploying PUQcloud to $ENVIRONMENT from $BRANCH branch..."
# Backup current installation
echo "πΎ Creating backup..."
./backup.sh
# Pull latest code
echo "π₯ Pulling latest code..."
git fetch --all
git checkout $BRANCH
git pull origin $BRANCH
# Install/update dependencies
echo "π¦ Installing dependencies..."
composer install --no-dev --optimize-autoloader
npm ci && npm run production
# Run migrations
echo "ποΈ Running migrations..."
php artisan migrate --force
# Clear caches
echo "π§Ή Clearing caches..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Restart services
echo "π Restarting services..."
php artisan horizon:terminate
supervisorctl restart horizon
php artisan queue:restart
# Run health checks
echo "π₯ Running health checks..."
./health-check.sh
echo "β
Deployment completed successfully!"
EOF
chmod +x deploy.sh
# Create rollback script
cat > rollback.sh << 'EOF'
#!/bin/bash
# Rollback script
BACKUP_FILE=${1}
if [ -z "$BACKUP_FILE" ]; then
echo "Usage: $0 <backup_file>"
echo "Available backups:"
ls -la /backups/puqcloud/
exit 1
fi
echo "π Rolling back to $BACKUP_FILE..."
# Stop services
supervisorctl stop horizon
# Restore backup
tar -xzf "/backups/puqcloud/$BACKUP_FILE" -C /
# Restart services
systemctl restart nginx php8.2-fpm
supervisorctl start horizon
echo "β
Rollback completed!"
EOF
chmod +x rollback.sh
echo "β
Deployment pipeline setup completed!"#!/bin/bash
# Performance optimization script
echo "π PUQcloud Performance Optimization..."
# Optimize database
echo "ποΈ Optimizing database..."
cd /var/www/puqcloud
php artisan optimize:clear
php artisan optimize
# Configure PHP-FPM for performance
echo "π Optimizing PHP-FPM..."
sed -i 's/pm.max_children = .*/pm.max_children = 50/' /etc/php/8.2/fpm/pool.d/www.conf
sed -i 's/pm.start_servers = .*/pm.start_servers = 10/' /etc/php/8.2/fpm/pool.d/www.conf
sed -i 's/pm.min_spare_servers = .*/pm.min_spare_servers = 5/' /etc/php/8.2/fpm/pool.d/www.conf
sed -i 's/pm.max_spare_servers = .*/pm.max_spare_servers = 15/' /etc/php/8.2/fpm/pool.d/www.conf
# Optimize Nginx
echo "π Optimizing Nginx..."
cat >> /etc/nginx/nginx.conf << 'EOF'
# Performance optimizations
worker_processes auto;
worker_connections 1024;
keepalive_timeout 65;
client_max_body_size 100M;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
EOF
# Setup Redis caching
echo "π Configuring Redis caching..."
sed -i 's/CACHE_DRIVER=.*/CACHE_DRIVER=redis/' .env
sed -i 's/SESSION_DRIVER=.*/SESSION_DRIVER=redis/' .env
# Restart services
systemctl restart php8.2-fpm nginx redis-server
echo "β
Performance optimization completed!"These examples cover the most common use cases and scenarios for PUQcloud deployment and management. Each script can be customized according to specific requirements and environments.