Skip to main content

๐Ÿ”ต IIS (Windows)

Running Monitron SaaS on Windows with IIS is fully supported. This guide walks you through the complete setup.


๐Ÿ“‹ Prerequisitesโ€‹

  • Windows Server 2019/2022 or Windows 10/11
  • IIS 10+ with URL Rewrite Module
  • PHP 8.2+ installed (via Web Platform Installer or manually)

๐Ÿ”ง Step 1: Install IIS & PHPโ€‹

Install IISโ€‹

  1. Open Server Manager โ†’ Add Roles and Features
  2. Select Web Server (IIS)
  3. Under Role Services, enable:
    • โœ… Common HTTP Features โ†’ Static Content, Default Document
    • โœ… Application Development โ†’ CGI
    • โœ… Security โ†’ Request Filtering

Install PHPโ€‹

  1. Download PHP 8.3 (Non Thread Safe) from windows.php.net
  2. Extract to C:\PHP
  3. Copy php.ini-production to php.ini
  4. Edit php.ini and enable required extensions:
extension_dir = "ext"
extension=bcmath
extension=curl
extension=fileinfo
extension=gd2
extension=mbstring
extension=openssl
extension=pdo_mysql ; or pdo_pgsql, pdo_sqlite
extension=sockets
extension=zip

Install URL Rewrite Moduleโ€‹

Download and install from iis.net


๐Ÿ“ Step 2: Web.configโ€‹

Create or verify the web.config file in public/:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- URL Rewriting for Laravel -->
<rewrite>
<rules>
<rule name="Redirect Trailing Slashes" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}" redirectType="301" />
</rule>
<rule name="Send Requests To Front Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>

<!-- Block .env file access -->
<security>
<requestFiltering>
<hiddenSegments>
<add segment=".env" />
</hiddenSegments>
<fileExtensions>
<add fileExtension=".env" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>

<!-- Default Document -->
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>

<!-- Custom Headers -->
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

๐ŸŒ Step 3: Create the IIS Siteโ€‹

  1. Open IIS Manager
  2. Right-click Sites โ†’ Add Website
  3. Fill in:
SettingValue
Site nameMonitron
Physical pathE:\monitron\public
Host nameyour-domain.com
Port80 (or 443 with SSL)
danger

Point to the public folder! NOT the root installation directory.


๐Ÿ”’ Step 4: Add SSLโ€‹

  1. In IIS Manager, select your site
  2. Click Bindings โ†’ Add
  3. Set Type to https, port 443
  4. Select your SSL certificate

For free SSL, use win-acme (Let's Encrypt for Windows):

# Download and run win-acme
wacs.exe --target iis --siteid 1 --installation iis

โฐ Step 5: Scheduled Task (Cron Equivalent)โ€‹

Windows uses Task Scheduler instead of cron:

  1. Open Task Scheduler
  2. Click Create Basic Task
  3. Name: Monitron Scheduler
  4. Trigger: Daily โ†’ set start time โ†’ Repeat every 1 minute for Indefinitely
  5. Action: Start a program
    • Program: C:\PHP\php.exe
    • Arguments: artisan schedule:run
    • Start in: E:\monitron

Or use PowerShell:

$action = New-ScheduledTaskAction -Execute "C:\PHP\php.exe" -Argument "artisan schedule:run" -WorkingDirectory "E:\monitron"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 1) -RepetitionDuration ([TimeSpan]::MaxValue)
Register-ScheduledTask -TaskName "Monitron Scheduler" -Action $action -Trigger $trigger -User "SYSTEM" -RunLevel Highest

๐Ÿ”„ Step 6: Queue Worker Serviceโ€‹

Use NSSM to run the queue worker as a Windows service:

# Download NSSM from nssm.cc
nssm install MonitronWorker "C:\PHP\php.exe" "artisan queue:work --sleep=3 --tries=3 --max-time=3600"
nssm set MonitronWorker AppDirectory "E:\monitron"
nssm set MonitronWorker Start SERVICE_AUTO_START
nssm start MonitronWorker

๐Ÿ› ๏ธ Troubleshootingโ€‹

500.19 Internal Server Errorโ€‹

The URL Rewrite module isn't installed:

# Install via Web Platform Installer or download from iis.net

PHP not processingโ€‹

Make sure PHP is configured as a handler in IIS:

  1. Select your site โ†’ Handler Mappings
  2. Add Module Mapping: *.php โ†’ FastCgiModule โ†’ C:\PHP\php-cgi.exe

Permission issuesโ€‹

Give IIS_IUSRS Modify permission on:

  • storage/
  • bootstrap/cache/