71 lines
2.2 KiB
Bash
Executable File
71 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# FibDash Nginx Development Setup Script
|
|
|
|
echo "🚀 Setting up Nginx for FibDash development..."
|
|
|
|
# Create logs directory
|
|
mkdir -p logs/nginx
|
|
|
|
# Check if nginx is installed
|
|
if ! command -v nginx &> /dev/null; then
|
|
echo "❌ Nginx is not installed. Please install nginx first:"
|
|
echo " Ubuntu/Debian: sudo apt-get install nginx"
|
|
echo " CentOS/RHEL: sudo yum install nginx"
|
|
echo " macOS: brew install nginx"
|
|
exit 1
|
|
fi
|
|
|
|
# Backup existing nginx configuration
|
|
if [ -f /etc/nginx/sites-available/default ]; then
|
|
echo "📋 Backing up existing nginx configuration..."
|
|
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup.$(date +%Y%m%d_%H%M%S)
|
|
fi
|
|
|
|
# Copy our nginx configuration
|
|
echo "📝 Installing FibDash nginx configuration..."
|
|
sudo cp nginx.dev.conf /etc/nginx/sites-available/fibdash-dev
|
|
sudo ln -sf /etc/nginx/sites-available/fibdash-dev /etc/nginx/sites-enabled/fibdash-dev
|
|
|
|
# Remove default site if it exists
|
|
if [ -f /etc/nginx/sites-enabled/default ]; then
|
|
echo "🗑️ Removing default nginx site..."
|
|
sudo rm /etc/nginx/sites-enabled/default
|
|
fi
|
|
|
|
# Test nginx configuration
|
|
echo "🧪 Testing nginx configuration..."
|
|
sudo nginx -t
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Nginx configuration is valid"
|
|
|
|
# Reload nginx
|
|
echo "🔄 Reloading nginx..."
|
|
sudo systemctl reload nginx
|
|
|
|
# Enable nginx to start on boot
|
|
sudo systemctl enable nginx
|
|
|
|
echo ""
|
|
echo "🎉 Nginx setup complete!"
|
|
echo ""
|
|
echo "📋 Setup Summary:"
|
|
echo " • Nginx config: /etc/nginx/sites-available/fibdash-dev"
|
|
echo " • Logs directory: ./logs/nginx/"
|
|
echo " • Frontend (via nginx): http://localhost/"
|
|
echo " • API (via nginx): http://localhost/api/"
|
|
echo " • Direct frontend: http://localhost:5001/"
|
|
echo " • Direct backend: http://localhost:5000/"
|
|
echo ""
|
|
echo "🚀 Next steps:"
|
|
echo " 1. Start your development servers: npm run dev"
|
|
echo " 2. Access your app at: http://localhost/"
|
|
echo ""
|
|
echo "💡 To add fibdash.local to your hosts file:"
|
|
echo " echo '127.0.0.1 fibdash.local' | sudo tee -a /etc/hosts"
|
|
|
|
else
|
|
echo "❌ Nginx configuration test failed. Please check the configuration."
|
|
exit 1
|
|
fi |