Laravel on IIS

Note: PHP for Windows comes in two flavors, Non Thread Safe (NTS) and Thread Save (TS). If you are using PHP as a FastCGI or CGI executable you need to use the NTS flavor. This is the only flavor you should be using for IIS and NginX. It’s also the preferred way to set up PHP on Apache. Reference

  • Install IIS with default settings and also with Applications\CGI enabled
  • Download the latest NTS (Non Thread Safe) 7.4 64 bit version of PHP - here
    • Unzip PHP Files to a folder C:\Program Files\PHP\
    • Add to above folder to System Path
    • Reboot
    • Rename php.ini-production → php.ini
  • Uncomment the line:
    extension_dir = "ext"
  • Uncomment the line:
  • Uncomment the line:
  • Add the following lines at the end of the php.ini file:
; Microsoft SQL for Laravel

Note - the installer auto updates the PHP ini file and enables the following two extensions:

  • composer global require laravel/installer
  • Create a laravel folder at C:\inetpub\laravel
  • Open a command line Run as Administrator and go to the above folder.
  • Create your laravel project, e.g.
    laravel new <project>
  • Open the folder on command line (run as an administrator)
    • composer require laravel/ui
    • php artisan ui vue --auth
  • After you do this run “npm install && npm run dev” to compile your fresh scaffolding.
    • Download latest stable NPM (e.g. 12.19.0 LTS) here

Summary of Steps

  • Copy your Laravel Project to C:\inetpub\laravel\<projectname>\
  • Give <servername>\IIS_IUSRS full access to the Storage folder
  • Create a virtual Directory for your Default Site to the public folder of your laravel project, e.g.
  • Example:
  • enable full access for the user <servername>\IIS_IUSRS for the laravel storage folder
  • Add the below IIS web.config file to the public folder
                <clear />
                <add value="index.php" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)/$" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <action type="Rewrite" url="index.php" />
        <httpErrors errorMode="Detailed" />
  • code/laravel/iis.txt
  • Last modified: 2021/05/15 20:22
  • by gerardorourke