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

  • Download the latest NTS (Non Thread Safe) 7.3 64 bit version of PHP
    • Unzip PHP Files to a folder C:\Program Files\PHP\v7.3\ (change version to whatever PHP version you are using)
    • Add to above folder to System Path
    • reboot
    • Rename php.ini-production → php.ini
  • Enable php for SQL
    • Download PHP SQL Drivers (ODBC Drivers)
      • https://docs.microsoft.com/en*us/sql/connect/php/download*drivers*php*sql*server?view=sql*server*ver15
      • Microsoft Drivers 5.6 for PHP for SQL Server
      • Run the installer / extractor and copy the below files to C:\Program Files\PHP\v7.4.2\ext\
  php_sqlsrv_73_nts_x64.dll
  php_sqlsrv_73_nts_x64.dll 
  • PHP.ini Config file
    • Uncomment the line:
      extension_dir = "ext"
  • Add the following lines at the end of the php.ini file:
; Microsoft SQL for Laravel
extension=php_pdo_sqlsrv_73_nts_x64
extension=php_sqlsrv_73_nts_x64
  • Install Laravel
composer global require laravel/installer

Configure IIS for your laravel project

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.
C:\inetpub\laravel\<projectname>\public\

e.g.

  • 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
web.config
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <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" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)/$" ignoreCase="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
</configuration>
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies