# 🚀 EXECUTE NOW - DEPLOYMENT COMMANDS

**START TIME:** March 28, 2026 | **STATUS:** EXECUTING  
**GOAL:** Deploy web-based installer to webhost  
**ESTIMATED TIME:** 90 minutes  

---

## ⚠️ IMPORTANT FIRST

Before you start, verify:
- [ ] You have SSH access to `tracker.lppmunud.id`
- [ ] You have webhost login credentials
- [ ] You have WinSCP or similar FTP client (optional but easier)
- [ ] You have a Windows 10/11 PC ready for testing
- [ ] You have ~90 minutes available

---

## 🟢 STEP 1: VERIFY LOCAL FILES (5 MINUTES)

Open PowerShell and verify files exist:

```powershell
# Navigate to tracker folder
cd e:\xampp\htdocs\tracker

# Verify all 3 files exist
Test-Path "dashboard/installer.php" -Verbose
Test-Path "api/controllers/InstallerController.php" -Verbose
Test-Path "api/index.php" -Verbose

# All should return TRUE
```

**Expected Output:**
```
Target          : e:\xampp\htdocs\tracker\dashboard/installer.php
Exist           : True
PathType        : File
PSPath          : Microsoft.PowerShell.Core\FileSystem::e:\xampp\htdocs\tracker\dashboard\installer.php
PSParentPath    : Microsoft.PowerShell.Core\FileSystem::e:\xampp\htdocs\tracker\dashboard
PSChildName     : installer.php
```

✅ **When TRUE for all 3 files** → Move to STEP 2

---

## 🟢 STEP 2: TEST LOCAL (10 MINUTES)

Test installer on local XAMPP before uploading:

```powershell
# Start XAMPP if not running
# - Open C:\xampp\xampp-control.exe
# - Click "Start" for Apache and MySQL

# Wait 5 seconds for services to start
Start-Sleep -Seconds 5

# Open installer in browser
start "http://localhost/tracker/dashboard/installer.php"

# Wait for page to load (~3 seconds)
Start-Sleep -Seconds 3
```

**What You Should See:**
```
✅ Beautiful purple/blue interface loads
✅ Title: "PC MONITOR AGENT - WEB INSTALLER"
✅ 5 feature badges visible
✅ System requirements list visible
✅ 4 step sections visible
✅ Download button visible
✅ Troubleshooting section visible
✅ Support info at bottom
✅ NO error messages
```

**If Page Shows 404 Error:**
```
❌ Problem: installer.php not found
✅ Fix:
   1. Verify file exists: dir dashboard\installer.php
   2. Verify XAMPP running: Apache should be green
   3. Verify Apache document root: C:\xampp\htdocs\
   4. Clear browser cache: Ctrl+F5
   5. Restart Apache in XAMPP control
   6. Try again
```

**If Page Shows Blank or Strange Characters:**
```
❌ Problem: File encoding issue
✅ Fix:
   1. Right-click installer.php
   2. Properties → Open With → Notepad
   3. File → Save As → UTF-8 encoding
   4. Refresh browser
```

✅ **When page loads perfectly** → Move to STEP 3

---

## 🟢 STEP 3: TEST SCRIPT GENERATION (5 MINUTES)

Test that PowerShell script generates correctly:

```powershell
# Test script download from local
$url = "http://localhost/tracker/dashboard/installer.php?action=api&do=get-installer-script"
$output = "C:\temp\PCMonitor-Install.ps1"

# Download script
Invoke-WebRequest -Uri $url -OutFile $output -Verbose

# Check file exists and size
Get-Item $output | Select-Object Name, Length, LastWriteTime

# View first 20 lines
Get-Content $output -TotalCount 20

# Verify correct content (should show PowerShell code)
```

**Expected Output:**
```
Name                           Length  LastWriteTime
----                           ------  -----

PCMonitor-Install.ps1          20480   3/28/2026 10:30:00 AM
```

**First 20 Lines Should Show:**
```
# ============================================================
# PC Monitor Agent - Automated Installation Script
# ============================================================
...
param(
    [string]$WebhostURL = "http://tracker.lppmunud.id",
    [string]$InstallPath = "C:\Program Files\PCMonitor",
    ...
)
```

**If File Downloaded but Wrong Content:**
```
❌ Problem: API not generating script
✅ Fix:
   1. Check api/index.php is updated
   2. Check InstallerController.php exists
   3. Verify PHP error logs: C:\xampp\apache\logs\error.log
   4. restart Apache
   5. Try again
```

✅ **When script downloads with correct content** → Move to STEP 4

---

## 🟢 STEP 4: UPLOAD TO WEBHOST (10 MINUTES)

This is the critical step. Use SSH/SCP:

### **METHOD A: Using PowerShell (Windows)**

```powershell
# Install OpenSSH client if needed (Windows 10/11)
# Settings → Apps → Optional Features → Add feature
# Search: OpenSSH Client → Install

# Variables
$sshHost = "tracker.lppmunud.id"
$sshUser = "user"  # Change to your webhost username
$sshPass = "password"  # Change to your password
$webgostPath = "/home/lppmunu1/public_html/tracker.lppmunud.id"

# Option 1: Using bash/SCP (if Windows OpenSSH installed)
# Can use: scp source user@host:destination

# Option 2: Using built-in SSH
ssh ${sshUser}@${sshHost} "ls -la ${webschostPath}/dashboard/installer.php"

# If successful, you'll see the file listed

# Upload file 1
scp E:\xampp\htdocs\tracker\dashboard\installer.php `
    ${sshUser}@${sshHost}:${webhostPath}/dashboard/

# Upload file 2  
scp E:\xampp\htdocs\tracker\api\controllers\InstallerController.php `
    ${sshUser}@${sshHost}:${webhostPath}/api/controllers/

# Upload file 3
scp E:\xampp\htdocs\tracker\api\index.php `
    ${sshUser}@${sshHost}:${webhostPath}/api/

# Verify uploads
ssh ${sshUser}@${sshHost} "ls -la ${webhostPath}/dashboard/installer.php"
ssh ${sshUser}@${sshHost} "ls -la ${webhostPath}/api/controllers/InstallerController.php"
```

### **METHOD B: Using WinSCP (Easier for Beginners)**

```
1. Download WinSCP: https://winscp.net/eng/download.php

2. Open WinSCP and connect:
   - Hostname: tracker.lppmunud.id
   - Port: 22
   - Username: [your username]
   - Password: [your password]
   - File protocol: SFTP

3. Navigate to: /home/lppmunu1/public_html/tracker.lppmunud.id

4. Locate and upload:
   - LOCAL: e:\xampp\htdocs\tracker\dashboard\installer.php
   - REMOTE: dashboard/installer.php
   
   - LOCAL: e:\xampp\htdocs\tracker\api\controllers\InstallerController.php
   - REMOTE: api/controllers/InstallerController.php
   
   - LOCAL: e:\xampp\htdocs\tracker\api\index.php
   - REMOTE: api/index.php

5. Verify files appear in remote directory

6. Close WinSCP
```

### **METHOD C: Using cPanel File Manager**

```
1. Login to cPanel (usually host:2083)

2. Navigate: File Manager → public_html → tracker.lppmunud.id

3. Upload 3 files:
   - dashboard/installer.php
   - api/controllers/InstallerController.php
   - api/index.php

4. Verify files uploaded

5. Set permissions to 644 (read-only for web):
   - Right-click each file
   - Change Permissions
   - Set to 644
```

**Expected After Upload:**
```
✅ dashboard/installer.php exists on webhost
✅ api/controllers/InstallerController.php exists
✅ api/index.php updated on webhost
✅ All files readable (644 permissions)
```

**If Upload Fails:**
```
❌ Problem: SSH/FTP connection fails
✅ Fix:
   1. Verify credentials (username/password)
   2. Verify hostname: tracker.lppmunud.id
   3. Try alternate port (21 for FTP, 22 for SSH)
   4. Check firewall isn't blocking
   5. Contact hosting provider for assistance
   
❌ Problem: Permission denied after upload
✅ Fix:
   1. SSH to server: ssh user@tracker.lppmunud.id
   2. Set permissions: chmod 644 /path/to/file
   3. Verify: ls -la /path/to/file
```

✅ **When all 3 files uploaded successfully** → Move to STEP 5

---

## 🟢 STEP 5: TEST WEBHOST (10 MINUTES)

Verify files work on webhost:

```powershell
# Test 1: Web interface loads
$url = "http://tracker.lppmunud.id/dashboard/installer.php"
Invoke-WebRequest -Uri $url -UseBasicParsing | Select-Object StatusCode, StatusDescription

# Should show: StatusCode 200, Description OK

# Test 2: Download script from webhost
$url = "http://tracker.lppmunud.id/dashboard/installer.php?action=api&do=get-installer-script"
$output = "C:\temp\PCMonitor-Install-Webhost.ps1"
Invoke-WebRequest -Uri $url -OutFile $output -Verbose

# Check file size
Get-Item $output | Select-Object Length

# Test 3: API endpoint test
$url = "http://tracker.lppmunud.id/api/installer?action=config"
Invoke-RestMethod -Uri $url -UseBasicParsing | ConvertTo-Json

# Should return JSON with config info
```

**Expected Outputs:**

**Test 1:**
```
StatusCode        : 200
StatusDescription : OK
```

**Test 2:**
```
Length  : ~20480 (approximately 20KB)
```

**Test 3:**
```json
{
  "success": true,
  "data": {
    "webhost_url": "http://tracker.lppmunud.id",
    "api_endpoint": "http://tracker.lppmunud.id/api",
    "installer_version": "1.0.0",
    ...
  }
}
```

**If Tests Fail:**

```
❌ Problem: 404 Not Found
✅ Fix:
   1. Verify file uploaded correctly
   2. Check permissions: chmod 644 file
   3. Verify path correct on webhost
   4. Check .htaccess not blocking
   5. Review webhost error log

❌ Problem: 500 Internal Server Error
✅ Fix:
   1. Check PHP syntax in file
   2. Review error logs: tail -f /var/log/apache2/error.log
   3. Verify PHP version compatible
   4. Check database connectivity

❌ Problem: JSON format error
✅ Fix:
   1. Check if PHP errors are showing
   2. Review webhost error logs
   3. Verify InstallerController.php syntax correct
```

✅ **When all 3 tests pass** → Move to STEP 6

---

## 🟢 STEP 6: TEST INSTALLATION (25 MINUTES)

Full installation test on Windows PC:

### **On Target Windows 10/11 PC:**

```powershell
# Step 1: Open PowerShell as Administrator
# Press: Win+X → Select "Windows PowerShell (Admin)"

# Step 2: Navigate to Downloads
cd $env:USERPROFILE\Downloads

# Step 3: Download installer script
$url = "http://tracker.lppmunud.id/dashboard/installer.php?action=api&do=get-installer-script"
Invoke-WebRequest -Uri $url -OutFile "PCMonitor-Install.ps1" -UseBasicParsing
Write-Host "Script downloaded successfully"

# Step 4: Verify script downloaded
Get-Item "PCMonitor-Install.ps1" | Select-Object Name, Length

# Step 5: Allow script execution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

# Step 6: RUN THE INSTALLATION
.\PCMonitor-Install.ps1

# Monitor progress output...
# Installation typically takes 5-10 minutes
```

**What You'll See During Installation:**

```
╔════════════════════════════════════════════╗
║      PC MONITOR AGENT - INSTALLER          ║
╚════════════════════════════════════════════╝

[10:30:45] [INFO] Starting PC Monitor Agent installation...

[10:30:46] [SUCCESS] Running as Administrator
[10:30:47] [INFO] Checking system requirements...
[10:30:48] [SUCCESS] .NET version: 6.0.12
[10:30:49] [SUCCESS] Windows 11 detected
[10:30:50] [INFO] Collecting system information...
[10:30:52] [SUCCESS] Computer: DESKTOP-ABC123 | MAC: 00:1A:2B:3C:4D:5E | User: admin

[10:30:55] [INFO] Downloading agent files...
[10:31:15] [SUCCESS] Downloaded: 75MB agent files
[10:31:20] [SUCCESS] Extracted agent files

[10:31:25] [INFO] Installing agent to: C:\Program Files\PCMonitor
[10:31:30] [SUCCESS] Files copied to installation directory

[10:31:35] [INFO] Installing Windows Service...
[10:31:40] [SUCCESS] Service created: PCMonitorAgent
[10:31:45] [SUCCESS] Service started

[10:31:50] [INFO] Registering agent with server...
[10:31:55] [SUCCESS] Agent ID: AGENT-ABC12345
[10:31:56] [SUCCESS] Agent registered successfully

[10:32:00] [INFO] Testing service...
[10:32:05] [SUCCESS] Service is running

════════════════════════════════════════════
║      INSTALLATION COMPLETED                ║
════════════════════════════════════════════
Service Name     : PCMonitorAgent
Install Path     : C:\Program Files\PCMonitor
Status           : Running ✅
Agent ID         : AGENT-ABC12345
Webhost URL      : http://tracker.lppmunud.id
Dashboard Link   : http://tracker.lppmunud.id/dashboard/agents

[10:32:10] [SUCCESS] Installation successful!
```

**If Installation Fails:**

```
❌ Error: "This script must run as Administrator!"
✅ Solution:
   - Right-click PowerShell
   - Select "Run as administrator"
   - Run script again

❌ Error: ".NET 6.0 SDK is required but not found"
✅ Solution:
   - Download: https://dotnet.microsoft.com/download
   - Install .NET 6.0 SDK (not just runtime)
   - Restart PowerShell
   - Run script again

❌ Error: "Failed to download agent"
✅ Solution:
   - Check internet connectivity
   - Ping: ping tracker.lppmunud.id
   - Check firewall isn't blocking port 80/443
   - Verify webhost is online
   - Check webhost error logs

❌ Error: "Service won't start"
✅ Solution:
   - Check logs: C:\Program Files\PCMonitor\logs\
   - Check .NET runtime available: dotnet --version
   - Try manual run: cd C:\Program Files\PCMonitor
   - Run debug: .\PCMonitorAgent.exe debug
   - Check error message in output
```

✅ **When installation completes successfully** → Move to STEP 7

---

## 🟢 STEP 7: VERIFY IN DASHBOARD (5 MINUTES)

Check agent appears in dashboard:

```powershell
# Open browser to dashboard
start "http://tracker.lppmunud.id/dashboard/agents"

# Wait for page to load (~3 seconds)
Start-Sleep -Seconds 3
```

**What You Should See:**

```
Agents Dashboard

╔═══════════════════════════════════════════════════════════════╗
║ Agents List                                                  ║
╠═══════════════════════════════════════════════════════════════╣
║                                                              ║
║ DESKTOP-ABC123                                  ✅ Active   ║
│ Computer Name: DESKTOP-ABC123                              │
│ MAC Address: 00:1A:2B:3C:4D:5E                             │
│ OS: Windows 11                                             │
│ Processor: Intel Core i7-10700K                            │
│ RAM: 16 GB                                                 │
│ Status: Active (green)                                     │
│ Last Seen: Just now                                        │
│ Created: 3/28/2026 10:32 AM                                │
│ [View Details] [Status] [Screenshots] [Activities]     │
╚═══════════════════════════════════════════════════════════════╝
```

**If Agent Doesn't Appear:**

```
❌ Problem: Agent not in list
✅ Solution:
   1. Wait 30-60 seconds (first heartbeat might be delayed)
   2. Refresh page (F5)
   3. Check database directly (see below)
   4. Check webhost registration logs
   5. Verify network connectivity from PC to webhost

Check database manually:
   1. SSH to webhost: ssh user@tracker.lppmunud.id
   2. Login to MySQL: mysql -u lppmunu1_tracker -p lppmunu1_tracker
   3. Query agents: SELECT * FROM agents ORDER BY created_at DESC LIMIT 1;
   4. You should see the newly registered agent
```

✅ **When agent appears in dashboard** → Move to STEP 8

---

## 🟢 STEP 8: VERIFY DATA FLOW (10 MINUTES)

Check agent is sending data:

```
In Dashboard, Click on Agent → View Details
```

**What Should Update Every 30 Seconds:**

```
✅ Last Seen: Updates to current time
✅ System Info: CPU, Memory, Disk info displays
✅ Screenshots: Latest screenshot displays
✅ Activities: Activity log starts showing entries
✅ Running Apps: List of applications displays
✅ Bandwidth: Network status displays
```

**If No Data:**

```
❌ Problem: Data not flowing
✅ Solution:
   1. Wait 2-3 minutes for first data packets
   2. Refresh page
   3. Check agent logs: C:\Program Files\PCMonitor\logs\
   4. Check firewall on target PC (allow outbound 80/443)
   5. Check webhost logs for data receiving errors
```

✅ **When data flowing and agent active** → **DEPLOYMENT COMPLETE!** 🎉

---

## ✅ COMPLETION CHECKLIST

Mark off as you complete each step:

- [ ] STEP 1: Local files verified (5 min)
- [ ] STEP 2: Local test successful (10 min)
- [ ] STEP 3: Script generation verified (5 min)
- [ ] STEP 4: Files uploaded to webhost (10 min)
- [ ] STEP 5: Webhost tests pass (10 min)
- [ ] STEP 6: Installation on target PC completes (25 min)
- [ ] STEP 7: Agent appears in dashboard (5 min)
- [ ] STEP 8: Data flowing from agent (10 min)

**TOTAL TIME: ~90 minutes**

---

## 📊 PROGRESS TRACKER

```
Start Time: _______________
Step 1 Completed: _______________
Step 2 Completed: _______________
Step 3 Completed: _______________
Step 4 Completed: _______________
Step 5 Completed: _______________
Step 6 Completed: _______________
Step 7 Completed: _______________
Step 8 Completed: _______________
End Time: _______________
Total Time: _______________
```

---

## 🎉 WHEN ALL COMPLETE

You have successfully:
✅ Deployed web-based installer to production  
✅ Verified web interface working  
✅ Downloaded and tested installation script  
✅ Installed agent on Windows PC  
✅ Registered agent in database  
✅ Agent active and sending data  
✅ Dashboard monitoring in real-time  

**Next Steps:**
1. Test on 5-10 more PCs
2. Document any issues
3. Create FAQ from common issues
4. Plan full rollout schedule
5. Deploy C# features

---

**LET'S GO! Follow the steps above. 🚀**

Need help at any step? Refer to the documentation files!
