How to build and deploy Laravel to IIS?

Laravel-klcweb

Laravel is a trendy PHP framework, many people want to build a laravel application but didn’t know how to build it. KLCWEB will explain how to build a Laravel application to your local development machine and publish it to Windows web hosting in the earliest way.

Let’s see how to Build your Laravel project.

=> You need to ensure that, you have installed PHP on your local development machine

=> Then, install composer, if you do not have a composer. You can download it from getcomposer.

=> Once you installed composer correctly, open the command prompt (win+R and type cmd) and type composer and you will see the below result.

Composer

=> If you see this kind of result, it means the composer installs successfully.

=> You need to change the directory from where you want to store your project, we recommended using C:/ intpub

cdpath

=> Once, you have this, we need to install the Laravel installer using this command:: composer global require “laravel/installer”

composer install

=> Let’s install laravel and access it, Just follow this command.

composer create-project laravel/laravel example-app

=> Note:- example-app is the project name, you can use customize name as per your need like Eshop, bookshop, etc.

= > next, cd example-app ( After CD mentioned the project’s folder that you have used while creating the project)

=> php artisan serve ( this command will start the laravel development server using the artisan CLI’s serve Command)

larvavel pj
cd laravel

=> Here is our project building completed, you can access your project using http://127.0.0.1:8000

=> 127.0.0.1:8000 is no fixed URL, it should be different for you. You can find it in the result.

=> Now, you can open a web browser and check your project.

Laravel site

Let’s deploy the Laravel project.

=> You need to upload all files to your hosting from the C:/intpub/your project folder (or from where you have built your project) via FTP. If you will host your project on a shared server, then, you need to ignore .bat files and these bat files are not mandatory so you can leave them.

=> Once, you have done site uploading, you can access your site with the real domain name that you have hosted. If you face any CSS related issues, Do not worry just create a web.config file and copy and paste the below code. Also, set the PHP version from your hosting service the same you have used the PHP version on your local development machine while building the project.

<?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>
Tagged : / /