Host a Laravel site on Plesk
Put a Laravel application online on Plesk, with or without Laravel Toolkit: PHP version, database, .env file, migrations, scheduled tasks and common errors.
On this page
Your values
Enter them once and the commands in this guide update.
This guide shows you how to publish a Laravel application on your Plesk hosting. It covers two methods: with Laravel Toolkit, the Plesk tool dedicated to Laravel, or manually if this tool is not available.
Prerequisites
- Access to your Plesk panel (see Connect to Plesk interface).
- A domain attached to your hosting and pointing to it.
- A PHP version compatible with your application. Laravel 13 requires PHP 8.3 or higher. For another Laravel version, check the
phpline in yourcomposer.jsonfile. - The PHP extensions required by Laravel: Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer and XML, plus
pdo_mysqlfor MySQL or MariaDB. - Your project, in a Git repository or on your computer.
This guide uses httpdocs, the usual folder for the main domain. For an additional domain, the folder may be different: check the Document root under Hosting & DNS > Hosting.
Key point: the public folder
Only Laravel's public folder should be reachable from the web. The rest of the project contains, among other things, the .env file with your passwords and encryption key. Never move index.php to the project root: the domain's document root must point to public.
With a project placed in httpdocs, the value to use is /httpdocs/public.
Step 1: choose the PHP version
- Go to Websites & Domains and find your domain.
- Open PHP (or PHP Settings, depending on your Plesk version).
- Select a compatible version, then save.
Step 2: create the database
Create a database and a dedicated user by following the Create a database guide. Write down the database name, the user, the password and the host shown by Plesk in the database connection information.
Method 1: with Laravel Toolkit
Install the application
In Websites & Domains, on your domain, click Create Website > Laravel, then choose one of these options:
- Install from remote repository: enter your repository URL. If it is private, add the public key displayed by Plesk to your repository (the process is explained in Deploy from GitHub or GitLab). Then click Install Application.
- Install Skeleton: Plesk installs a blank Laravel application. Click Install Application, then, if you already have a project, replace the files with your own over FTP or with the file manager.
If your application is already on your hosting:
- Under Hosting & DNS > Hosting, set Document root to
/httpdocs/public, then click Save. - Go back to the Dashboard tab, click Create Website > Laravel, then Cancel.
- Click Scan so that Plesk detects the application.
Configure the .env file
Open Laravel from your domain. Next to Environment variables (.env), click Edit, adjust the following values, then click Update:
APP_NAME="My application"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME=database_user
DB_PASSWORD=database_passwordRun the Artisan commands
In the Artisan tab, enter each command without the php artisan prefix, then run it:
key:generate --force
migrate --force
storage:link
optimizekey:generate --forcecreates theAPP_KEYkey. Run it only if this value is empty: changing the key of a live site makes encrypted data unreadable and logs users out.migrate --forcecreates the tables. By default, Laravel also stores sessions, cache and queues there.storage:linkmakes the files on thepublicdisk accessible.optimizecaches the configuration, routes, events and views.
Deploy updates
In the Deployment tab:
- Choose the Deployment mode: Manual or Automatic.
- Under Deployment scenario, clear the steps you do not need.
- Click Deploy.
The Edit script button lets you customize the deployment, provided SSH access is allowed for the domain.
Enable scheduled tasks
Tasks are defined in the application code, usually in routes/console.php. They cannot be created from Plesk. Once at least one task exists, the Scheduled Tasks tab appears: set its toggle to Enabled.
Enable queues
Queues in Laravel Toolkit rely on the database and on scheduled tasks, which must therefore be enabled.
-
Add the Plesk integration package to the
requiresection ofcomposer.json, checking that it is compatible with your Laravel version:JSON"plesk/ext-laravel-integration": "^7.0" -
Deploy, then commit the updated
composer.lockfile and deploy again. -
Check that
QUEUE_CONNECTION=databaseis present in the.envfile. -
Turn on Maintenance mode.
-
In Artisan, run
migrate --force. If your project does not contain a migration for thejobstable, runqueue:tablefirst. -
Turn off Maintenance mode, then set the Queue toggle to Enabled.
Method 2: without Laravel Toolkit
Prepare the project on your computer
From the project folder, install the production dependencies and build the front-end files:
composer install --no-dev --optimize-autoloader
npm ci
npm run build
php artisan key:generate --showKeep the key displayed by the last command: it starts with base64:. If your site is already live, reuse its current key instead.
Upload the files
-
Create a
.ziparchive of the project, including thevendorandpublic/buildfolders, but withoutnode_modulesor your local.envfile. -
In Files, open
httpdocs, upload the archive, select it, click Extract Files, then delete it. -
Create a
.envfile inhttpdocsbased on the example from method 1, and add your key to it:ConfigurationAPP_KEY=base64:YOUR_GENERATED_KEY
You can also use an FTP account to upload the files.
Set the document root
- In Websites & Domains, open Hosting & DNS > Hosting for your domain.
- Set Document root to
/httpdocs/public. - Click Save.
Run the Artisan commands
With SSH access, use the PHP binary matching the version chosen for the site. The php command on its own may point to a different version:
cd httpdocs
/opt/plesk/php/8.3/bin/php artisan migrate --force
/opt/plesk/php/8.3/bin/php artisan storage:link
/opt/plesk/php/8.3/bin/php artisan optimizeWithout SSH access, use scheduled tasks:
- Open Scheduled Tasks, then click Add Task.
- Choose Run a PHP script.
- Select the
httpdocs/artisanfile with the folder icon. - In the arguments field (with arguments), enter
migrate --force. - Select the PHP version used by the site.
- Click Run Now and wait for the result.
Repeat the operation with storage:link, then optimize. You can then cancel without saving the task.
Schedule Laravel tasks
If your application uses the scheduler, create a Run a PHP script task as above, with the schedule:run argument and the following frequency, in Cron style:
* * * * *Check the result
-
Open
https://your-domain.com/: your application should be displayed. -
Test Laravel's health route, present by default in recent projects:
Terminalcurl -i https://your-domain.com/upA
200status code means that the application started without errors. -
Check that no sensitive file is exposed:
https://your-domain.com/.envmust never display your configuration. -
Test a page that uses the database, such as the login page.
Troubleshooting
500 error with no details
Check storage/logs/laravel.log from the file manager, or use the Logs button in Laravel Toolkit. Only turn on APP_DEBUG=true briefly if the log is not enough.
No application encryption key has been specified.
The APP_KEY variable is empty or missing. Generate it with key:generate --force, or paste the key created on your computer, then run config:clear.
Your .env changes are ignored
The configuration is cached. Run optimize:clear, then optimize once the problem is solved.
403 or 404 error, or a file listing on the home page
The document root probably does not point to public. Check that it is set to /httpdocs/public. If only inner pages return a 404 error, check that the public/.htaccess file was uploaded.
Vite manifest not found at: .../public/build/manifest.json
The front-end files were not built or uploaded. Run npm run build, then upload the public/build folder.
SQLSTATE[HY000] [1045] Access denied
The database user or password is incorrect, or the user is not associated with this database. Correct the .env file, then run config:clear. If the password contains spaces or the # character, put it in quotes.
SQLSTATE[HY000] [2002]
Laravel cannot reach the database server. Check DB_HOST and DB_PORT against the database connection information. If the message says No such file or directory with localhost, try DB_HOST=127.0.0.1.
SQLSTATE[42S02]: sessions or cache table not found
The migrations have not been run on this database. Run migrate --force.
Failed to open stream: Permission denied in storage
Laravel must be able to write to storage and bootstrap/cache. Check the permissions of these folders in the file manager. If you cannot correct them, contact support.
Your Composer dependencies require a PHP version ">= 8.3.0"
The site or the command line is using a PHP version that is too old. Select the right version in Plesk and, over SSH, call the full binary path, for example /opt/plesk/php/8.3/bin/php.
Uploaded images return a 404 error
The link to public storage is missing or was lost during a deployment. Run storage:link again.
The Scheduled Tasks tab does not appear
It is only displayed if the application defines at least one task. Check routes/console.php, then run a new deployment.