How to build and deploy Laravel to IIS?

Programming, error messages and sample code > PHP
Laravel is a very popular PHP framework, we fully support it, many of our customers are hosting their Laravel sites in our shared web server, the this KB will explain you on how to build a Laravel application and how to publish it to IIS.
 
 
Build your Laravel project:
  • First of all, you need to make sure PHP is installed in local pc.
  • Download and install composer at https://getcomposer.org/download/
  • Once composer installed, open command prompt and input "composer", you will get this page(this means composer is intalled successfully)
       
  
  • Change directory to the folder where you want to place your Laravel application, this time I would place it in in local folder C:\inetpub
   
 
  • Install Laravel installer via composer: composer global require "laravel/installer"
  • Install Laravel and access it using below commands:
    • composer create-project laravel/laravel example-app  (Create project called "example-app", you can customize the name )
    • cd example-app  (cd to your project folder)
    • php artisan serve (tart Laravel's local development server using the Artisan CLI's serve command:)
 
 
  • From the about command response, you can find out  that your your Laravel project URL is http://127.0.0.1:8000 (Please note you may get different URL address). Congratulations, you have Laravel project created.
 
Deploy Laravel to your hosting account.
  • Upload all files under C:\inetpub\example-app via FileZilla to your hosting account site root folder, you will notice some bat files are not allowed to be uploaded, don't worry, just ignore them.
  • Access your online website: http://yourdomain.com/server.php (Make sure you selected the accordingly php version for you site in your hosting control panel), if you get CSS not loading issue, it can be easy fixed by creating a web.confg file in your site root folder and in the file copy below code into it and save it.(Replace yourdomain.com to your real domain)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
       <defaultDocument>
           <files>
               <clear />
               <add value="index.php" />
           </files>
       </defaultDocument>
       <rewrite>
           <rules>
               <rule name="Laravel Force public">
                   <match url="(.*)" ignoreCase="false" />
                   <action type="Rewrite" url="public/{R:1}" />
               </rule>
               <rule name="Laravel Routes" stopProcessing="true">
                   <conditions>
                       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                   </conditions>
                   <match url="^" ignoreCase="false" />
                   <action type="Rewrite" url="public/index.php" />
               </rule>
           </rules>
       </rewrite>
   </system.webServer>
</configuration>