# IIS Server-ல் Node.js App Host செய்வது - Step by Step Guide ## Prerequisites (முன் தேவைகள்) 1. **Node.js Installation** - Node.js 18.x அல்லது அதற்கு மேல் install செய்ய வேண்டும் - Download: https://nodejs.org/ - Installation பிறகு, Command Prompt-ல் `node --version` run செய்து verify செய்யவும் 2. **iisnode Module Installation** - Download: https://github.com/Azure/iisnode/releases - Latest version-ஐ download செய்து install செய்யவும் - Install பிறகு IIS-ஐ restart செய்யவும் 3. **IIS Features Enable செய்யவும்** - Windows Features-ல் இவை enable செய்யவும்: - Internet Information Services (IIS) - IIS Management Console - URL Rewrite Module (https://www.iis.net/downloads/microsoft/url-rewrite) - Application Request Routing (ARR) - Optional ## Step 1: Project Build செய்யவும் ```powershell # Project root directory-ல் npm install npm run build ``` ## Step 2: IIS-ல் Website Create செய்யவும் ### Method 1: IIS Manager-ல் Manual Setup 1. **IIS Manager** open செய்யவும் 2. **Connections** pane-ல் server name-ஐ right-click செய்து **Add Website** select செய்யவும் 3. Fill செய்யவும்: - **Site name**: `PozoApp` (அல்லது உங்கள் விருப்பத்திற்கு) - **Application pool**: New application pool create செய்யவும் - **Physical path**: `D:\2025\Pozo Dev\PozoDev Updated OptimandSEO\Nov 7\dist` - **Binding**: - Type: `http` - IP address: `All Unassigned` (அல்லது specific IP) - Port: `80` (அல்லது வேறு port) - Host name: (optional) `pozo.app` அல்லது `www.pozo.app` 4. **OK** click செய்யவும் ### Method 2: PowerShell-ல் Script ```powershell # Run as Administrator Import-Module WebAdministration $siteName = "PozoApp" $physicalPath = "D:\2025\Pozo Dev\PozoDev Updated OptimandSEO\Nov 7\dist" $port = 80 # Create Application Pool New-WebAppPool -Name $siteName Set-ItemProperty IIS:\AppPools\$siteName -Name managedRuntimeVersion -Value "" # Create Website New-Website -Name $siteName -PhysicalPath $physicalPath -Port $port -ApplicationPool $siteName ``` ## Step 3: Application Pool Configuration 1. IIS Manager-ல் **Application Pools** select செய்யவும் 2. உங்கள் application pool-ஐ select செய்யவும் 3. **Advanced Settings** open செய்யவும் 4. இவை set செய்யவும்: - **.NET CLR Version**: `No Managed Code` - **Enable 32-Bit Applications**: `False` (64-bit Node.js-க்கு) - **Start Mode**: `AlwaysRunning` (optional, auto-start-க்கு) - **Idle Timeout**: `0` (idle-ல stop ஆகாமல்) ## Step 4: Environment Variables Setup (Optional) Application Pool-க்கு environment variables set செய்யலாம்: ```powershell # Run as Administrator $appPoolName = "PozoApp" $env = Get-ItemProperty "IIS:\AppPools\$appPoolName" -Name environmentVariables $env.Add("NODE_ENV", "production") $env.Add("PORT", "process.env.PORT") $env.Add("API_URL", "https://api.pozo.app") $env.Add("PRODUCTION_URL", "https://www.pozo.app") Set-ItemProperty "IIS:\AppPools\$appPoolName" -Name environmentVariables -Value $env ``` ## Step 5: Permissions Setup `dist` folder-க்கு IIS application pool identity-க்கு permissions கொடுக்கவும்: ```powershell # Run as Administrator $folderPath = "D:\2025\Pozo Dev\PozoDev Updated OptimandSEO\Nov 7\dist" $appPoolName = "PozoApp" $identity = "IIS AppPool\$appPoolName" # Full control permissions icacls $folderPath /grant "${identity}:(OI)(CI)F" /T ``` ## Step 6: Verify web.config `dist` folder-ல் `web.config` file உள்ளதா check செய்யவும். இது already configure செய்யப்பட்டிருக்கும். ## Step 7: Test the Application 1. IIS Manager-ல் website-ஐ **Start** செய்யவும் 2. Browser-ல் open செய்யவும்: - `http://localhost` (port 80-க்கு) - அல்லது `http://localhost:PORT` (custom port-க்கு) ## Troubleshooting (பிரச்சனைகள் தீர்த்தல்) ### Error: "iisnode module not found" - iisnode install செய்யப்பட்டதா verify செய்யவும் - IIS-ஐ restart செய்யவும் ### Error: "Cannot find module" - `dist` folder-ல் `node_modules` folder உள்ளதா check செய்யவும் - Project root-ல் `npm install` run செய்யவும் - `dist` folder-க்கு `node_modules` copy செய்யவும்: ```powershell xcopy /E /I /Y "node_modules" "dist\node_modules" ``` ### Error: "Port already in use" - IIS-ல் binding-ஐ check செய்யவும் - வேறு port use செய்யவும் ### Error: "500 Internal Server Error" - IIS logs check செய்யவும்: `C:\inetpub\logs\LogFiles\` - iisnode logs check செய்யவும்: `dist\iisnode\` folder - Application Pool-ல் **Advanced Settings** → **Process Model** → **Identity**-ஐ check செய்யவும் ### Static Files Load ஆகாமல் - `web.config`-ல் static content rules சரியாக configure செய்யப்பட்டதா check செய்யவும் - IIS-ல் **Static Content** feature enable செய்யப்பட்டதா verify செய்யவும் ### ES Modules Error - Node.js version 18+ install செய்யப்பட்டதா verify செய்யவும் - `package.json`-ல் `"type": "module"` உள்ளதா check செய்யவும் ## Logs Check செய்யவும் 1. **IIS Logs**: `C:\inetpub\logs\LogFiles\W3SVC[SiteID]\` 2. **iisnode Logs**: `dist\iisnode\` folder 3. **Application Logs**: Event Viewer → Windows Logs → Application ## Production Deployment Tips 1. **HTTPS Setup**: SSL certificate install செய்து HTTPS enable செய்யவும் 2. **Firewall**: Port 80/443 open செய்யவும் 3. **Domain**: DNS-ல் domain point செய்யவும் 4. **Monitoring**: Application performance monitor செய்யவும் 5. **Backup**: Regular backup எடுக்கவும் ## Quick Commands ```powershell # Website start Start-Website -Name "PozoApp" # Website stop Stop-Website -Name "PozoApp" # Application Pool restart Restart-WebAppPool -Name "PozoApp" # Check website status Get-Website -Name "PozoApp" # View application pool status Get-WebAppPoolState -Name "PozoApp" ``` ## Support பிரச்சனைகள் இருந்தால்: 1. IIS logs check செய்யவும் 2. iisnode logs check செய்யவும் 3. Node.js version verify செய்யவும் 4. Permissions verify செய்யவும்