Upload files to "/"
This commit is contained in:
@@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ==============================================================================
|
||||||
|
# FEDORA SERVER DEPLOYMENT SCRIPT (React + Vite + Nginx)
|
||||||
|
# ==============================================================================
|
||||||
|
# This script configures a Fedora Server to host your Fedora-PIS website.
|
||||||
|
# It handles Nginx setup, Firewall rules, and SELinux permissions.
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# --- CONFIGURATION ---
|
||||||
|
DOMAIN="10.1.22.62" # Replace with your actual domain or new IP
|
||||||
|
INSTALL_DIR="/var/www/fedora-website"
|
||||||
|
|
||||||
|
echo "🚀 Starting deployment on Fedora Server..."
|
||||||
|
|
||||||
|
# 1. Update and Install Dependencies
|
||||||
|
echo "📦 Installing Nginx, Node.js, and Security Tools..."
|
||||||
|
sudo dnf update -y
|
||||||
|
sudo dnf install -y nginx nodejs git certbot python3-certbot-nginx
|
||||||
|
|
||||||
|
# 2. Prepare Directory
|
||||||
|
echo "📁 Setting up web directory at $INSTALL_DIR..."
|
||||||
|
sudo mkdir -p $INSTALL_DIR
|
||||||
|
sudo chown -R $USER:$USER $INSTALL_DIR
|
||||||
|
|
||||||
|
# 3. Build the Project
|
||||||
|
echo "🏗️ Building the React application..."
|
||||||
|
cd $INSTALL_DIR
|
||||||
|
if [ -f "package.json" ]; then
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
else
|
||||||
|
echo "⚠️ Warning: No package.json found. Make sure your files are in $INSTALL_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Configure Nginx
|
||||||
|
echo "⚙️ Configuring Nginx for $DOMAIN..."
|
||||||
|
cat <<EOF | sudo tee /etc/nginx/conf.d/fedora-website.conf
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name $DOMAIN;
|
||||||
|
root $INSTALL_DIR/dist;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Serve the post-install script as plain text
|
||||||
|
location = /linux {
|
||||||
|
default_type text/plain;
|
||||||
|
try_files /linux =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Support for React Router / SPA navigation
|
||||||
|
location / {
|
||||||
|
try_files \$uri \$uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimized Caching for Static Assets
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public, no-transform";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Security Headers
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 5. Configure Firewall
|
||||||
|
echo "🔥 Opening HTTP/HTTPS ports in Firewall..."
|
||||||
|
sudo firewall-cmd --permanent --add-service=http
|
||||||
|
sudo firewall-cmd --permanent --add-service=https
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
|
||||||
|
# 6. SELinux Permissions (CRITICAL for Fedora)
|
||||||
|
echo "🛡️ Configuring SELinux contexts..."
|
||||||
|
# Allow Nginx to read the build directory
|
||||||
|
sudo chcon -Rt httpd_sys_content_t $INSTALL_DIR/dist
|
||||||
|
# Optional: Allow Nginx to connect to the network (if using proxies)
|
||||||
|
sudo setsebool -P httpd_can_network_connect 1
|
||||||
|
|
||||||
|
# 7. Start Services
|
||||||
|
echo "🔄 Starting Nginx..."
|
||||||
|
sudo systemctl enable --now nginx
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
|
||||||
|
echo "======================================================================"
|
||||||
|
echo "✅ DEPLOYMENT SUCCESSFUL"
|
||||||
|
echo "======================================================================"
|
||||||
|
echo "URL: http://$DOMAIN"
|
||||||
|
echo "Script: http://$DOMAIN/linux"
|
||||||
|
echo "======================================================================"
|
||||||
Reference in New Issue
Block a user