Run a Laravel application
Build a Laravel application locally, upload it and add the web.config that routes requests to the public folder.
Laravel is a modern PHP framework that runs well on our hosting. You prepare the application on your computer, upload it into /wwwroot and add a web.config that sends requests to Laravel's public folder.
Important
You cannot run Composer commands on our server. Run all necessary Composer commands locally on your computer before you upload the application.
Build the application locally
You need:
- PHP 8.3 or newer — php.net
- Composer, the PHP dependency manager — getcomposer.org
Check Composer
Install PHP and Composer and make sure both work. You can verify the Composer installation with:
composer -VInstall the Laravel installer
composer global require laravel/installerCreate a project
Create a new example application:
composer create-project laravel/laravel example-appRun it locally
Switch to the
example-appdirectory and start the application:cd example-app php artisan serveOpen
http://127.0.0.1:8000/in your browser to see the running application.
If you already have your own Laravel application, skip this part.
Select the PHP version of the website
In the Control Panel go to Websites, select your website and choose Scripting. In the PHP card select the PHP Version your application needs and click Save. See Run PHP on your website.
Deploy the application
All Laravel files must be located in /wwwroot, the root directory of your website. A Laravel project contains thousands of small files, so the deployment method matters:
| Method | Speed |
|---|---|
| Web Deploy from the command line | Fastest |
| ZIP archive uploaded and extracted on the server | Fast |
| FTP / SFTP with FileZilla | Slower |
With FileZilla, open the local folder of your Laravel application in the left panel, select all files and folders and drag them into wwwroot in the right panel.
Add the web.config
For Laravel URL routing to work you also have to upload this web.config into /wwwroot:
<?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>
The first rule rewrites every request into the public folder. The second rule sends everything that is not an existing file or directory to Laravel's front controller, public/index.php.
Your Laravel application is now deployed. Open the address of your website to see it.
File storage without storage:link
Laravel normally exposes uploaded files through a symbolic link from public/storage to storage/app/public, created with php artisan storage:link. On Windows this command calls mklink through exec(), and both exec() and symlink() are disabled on our shared hosting for security reasons. They cannot be enabled, so storage:link will not work here.
The recommended approach is to skip the link completely and point the public disk directly to public/storage. In config/filesystems.php change the public disk to:
'public' => [
'driver' => 'local',
'root' => public_path('storage'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Storage::disk('public') then writes straight into public/storage and the generated URLs stay the same, so the rest of your application does not need any changes.
Note
Create the public/storage folder before the first upload if it does not exist yet, and upload it together with the rest of the application.
PostgreSQL connection
If your application uses one of our PostgreSQL databases, enable emulated prepared statements for the pgsql connection in config/database.php:
'pgsql' => [
'driver' => 'pgsql',
// ... host, port, database, username, password ...
'options' => [
PDO::ATTR_EMULATE_PREPARES => true,
],
],
Without this option php artisan migrate and other code that runs several statements in one transaction fails with SQLSTATE[25P02]: current transaction is aborted. The reason is an incompatibility between server-side prepared statements in pdo_pgsql and the connection pooler in front of our PostgreSQL servers. See PostgreSQL: use emulated prepared statements for details.