Skip to main content

How to run Laravel application

This article provides step-by-step guide on how to run Laravel PHP application on MonsterASP.NET hosting.

ASP.NET hosting / .NET Freehosting
If you don’t already have our ASP.NET hosting / .NET Freehosting, sign up for FREE at https://MonsterASP.net/.

Laravel

Laravel is modern PHP framework that runs smoothly on our MonsterASP.NET hosting platform.
This guide will walk you through everything you need to deploy and run your Laravel application on our hosting websites.

2) Build your Laravel application locally

Requirements:

First install PHP and Composer on your local computer and make sure both are working correctly.
You can verify Composer installation by running this command:

composer -V

Composer_version.png

Install Laravel

If PHP and Composer are installed, you can install Laravel installer using Composer:

composer global require laravel/installer
Create Laravel project

After installing PHP, Composer and Laravel installer, you’re ready to create new Laravel example application:

composer create-project laravel/laravel example-app

Once your Laravel example application has been successfully created, switch your command prompt to example-app directory and run application with php artisan serve command:

cd example-app
php artisan serve

Laravel_run_on_local.png

Open your web browser and access your running Laravel application at: http://127.0.0.:8000/

Laravel_run_on_local_browser.png

Done! Your Laravel application is up and running on your local computer.

2) Setup PHP for your website

In our hosting Control panel enable and select correct PHP version:
Control panel -> Websites -> Manage -> Scripting -> select PHP version

Control_panel_switch_php_version.png

3) Deploy Laravel to your website

Now that you have created your Laravel example app and configured PHP version on website, you can deploy your application to our hosting platform.
There are several deployment options available:

Deployment options:

In this example we’ll use last option FileZilla via FTP/SFTP to deploy your Laravel PHP application.
Run Filezilla on your local computer and in left panel navigate to directory where your Laravel application files are stored locally.
Select all files and folders and drag them into right panel, into your website root directory \wwwroot.

Laravel_deploy_via_Filezilla.png

Folder \wwwroot is your website root directory and all Laravel PHP files must be located inside it.

Required web.config file:

To make Laravel URL routing work correctly you also need to upload required web.config file into /wwwroot folder.

web.config file content:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

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

    <rewrite>
      <rules>

        <!-- Rewrite everything to /public folder -->
        <rule name="Laravel to public">
          <match url="(.*)" ignoreCase="false" />
          <!-- Rewrite request to the public folder -->
          <action type="Rewrite" url="public/{R:1}" />
        </rule>

        <!-- Handle Laravel routes inside /public folder -->
        <rule name="Laravel Routes" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <!-- Skip if requested file or directory physically exists -->
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <!-- Send all other requests to Laravel front controller -->
          <action type="Rewrite" url="public/index.php" />
        </rule>

      </rules>
    </rewrite>

  </system.webServer>
</configuration>

Done! Your Laravel PHP application is now deployed and ready to run on your website.

Note: You cannot run Composer commands on our server. All necessary Composer commands must be executed locally on your computer before uploading your Laravel application to website.