# Sky Art Shop - Linux Server Migration Guide **Migration:** Windows IIS β†’ Linux with Nginx + Systemd **Goal:** Zero-downtime deployments, better stability, auto-reload on file changes --- ## 🎯 Why Linux? βœ… **Zero-downtime deployments** - Systemd can reload without dropping connections βœ… **Better stability** - No port conflicts, no Default Web Site issues βœ… **Auto-reload** - File changes auto-reload without manual restarts βœ… **Lower resource usage** - More efficient than IIS βœ… **Industry standard** - Most .NET Core production apps run on Linux --- ## πŸ“‹ Part 1: Linux Server Setup ### Recommended Options **Option A: Local Ubuntu Server (Recommended for you)** - Use Ubuntu 22.04 LTS Server - Can run on same Windows PC using WSL2 or separate machine - Free and full control **Option B: Cloud VPS** - DigitalOcean: $6/month - Linode: $5/month - Vultr: $6/month ### Step 1: Install Ubuntu Server **If using WSL2 on Windows:** ```powershell # In Windows PowerShell (Admin) wsl --install -d Ubuntu-22.04 # Launch Ubuntu wsl -d Ubuntu-22.04 ``` **If using separate Linux machine:** - Download Ubuntu 22.04 Server: - Install on dedicated machine or VM --- ## πŸ“¦ Part 2: Install Required Software on Linux ### Update System ```bash sudo apt update && sudo apt upgrade -y ``` ### Install .NET 8.0 Runtime ```bash # Add Microsoft package repository wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb # Install .NET Runtime and SDK sudo apt update sudo apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 # Verify installation dotnet --version ``` ### Install MongoDB on Linux ```bash # Import MongoDB public GPG key curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \ sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor # Add MongoDB repository echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \ sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list # Install MongoDB sudo apt update sudo apt install -y mongodb-org # Start MongoDB sudo systemctl start mongod sudo systemctl enable mongod # Verify MongoDB is running sudo systemctl status mongod mongosh --eval "db.version()" ``` ### Install Nginx (Web Server / Reverse Proxy) ```bash sudo apt install -y nginx # Start and enable Nginx sudo systemctl start nginx sudo systemctl enable nginx # Verify Nginx is running sudo systemctl status nginx ``` --- ## πŸ“€ Part 3: Export Data from Windows MongoDB ### On Windows ```powershell # Create export directory New-Item -ItemType Directory -Path "E:\mongodb_backup" -Force # Export MongoDB database (run in PowerShell) $mongoExport = "C:\Program Files\MongoDB\Server\8.0\bin\mongodump.exe" if (Test-Path $mongoExport) { & $mongoExport --db SkyArtShopDB --out "E:\mongodb_backup" Write-Host "βœ… MongoDB data exported to E:\mongodb_backup" } else { # Alternative: Use mongodump from command line mongodump --db SkyArtShopDB --out "E:\mongodb_backup" } # Export SQLite Identity database Copy-Item "E:\Documents\Website Projects\Sky_Art_Shop\identity.db" "E:\mongodb_backup\identity.db" # Export uploaded images Copy-Item "E:\Documents\Website Projects\Sky_Art_Shop\wwwroot\uploads\images\*" "E:\mongodb_backup\images\" -Recurse Write-Host "βœ… All data exported successfully" # # Transfer files to Ubuntu VM using SCP (PuTTY/PSCP) # Make sure you have PSCP.exe from PuTTY installed # Example (replace with your actual username and IP): pscp -pw PTBelize@3030! -r "E:\mongodb_backup" PTS@192.168.10.129:/home/PTS/ ``` --- ## πŸ“ Part 4: Transfer Files to Linux ### Method 1: Using SCP (if Linux is separate machine) ```powershell # On Windows, transfer files scp -r "E:\mongodb_backup" username@linux-server-ip:/home/username/ scp -r "E:\Documents\Website Projects\Sky_Art_Shop" username@linux-server-ip:/home/username/skyartshop ``` ### Method 2: Using WSL2 (if running on same Windows machine) ```powershell # Files are accessible at /mnt/e/ in WSL # In WSL terminal: ``` ```bash # Copy files to Linux home directory cp -r /mnt/e/mongodb_backup ~/mongodb_backup cp -r "/mnt/e/Documents/Website Projects/Sky_Art_Shop" ~/skyartshop ``` --- ## πŸ“₯ Part 5: Import Data to Linux MongoDB ```bash # Navigate to backup directory cd ~/mongodb_backup # Import MongoDB data mongorestore --db SkyArtShopDB ./SkyArtShopDB # Verify data imported mongosh --eval "use SkyArtShopDB; db.Products.countDocuments()" # Create MongoDB user for security (optional but recommended) mongosh < **Admin panel:** --- ## πŸ“ž Need Help? Common resources: - ASP.NET Core on Linux: - Ubuntu Server Guide: - MongoDB on Ubuntu: - Nginx Documentation: --- **Ready to migrate? Start with Part 1!** πŸš€