Logo

How to Host a Laravel Website on Plesk

How to Host a Laravel Website on Plesk

This guide explains how to install, configure, and manage Laravel applications on a Plesk server. Laravel is a popular PHP framework that makes building web applications easier with its elegant syntax and powerful features.

How to Host a Laravel Website on Plesk

What You'll Need

Before starting, make sure you have:

  • A Plesk server with the Laravel Toolkit extension installed
  • Your Laravel application ready to upload (or create a new one)
  • Database access (MySQL/MariaDB)
  • Basic knowledge of Laravel

Note: This guide assumes your hosting provider has already installed the Laravel Toolkit extension. If the Laravel option doesn't appear in your Plesk panel, contact your hosting provider.

What is Laravel Toolkit?

The Laravel Toolkit is a Plesk extension that simplifies hosting Laravel applications. It provides:

  • One-click Laravel installation - Create new Laravel apps instantly
  • Integrated tools - PHP, Composer, Artisan, npm, MySQL, and Git all in one place
  • No SSH required - Manage everything from Plesk interface
  • Artisan commands - Run Laravel commands directly from the panel
  • Git integration - Deploy and update from remote repositories
  • Environment management - Edit .env files easily
  • Log viewing - Access Laravel logs from Plesk
  • Automatic SSL - Secure your application with Let's Encrypt

Method 1: Create a New Laravel Application

This is the easiest way to get started with Laravel on Plesk.

Step 1: Add a New Domain

  1. Log in to Plesk
  2. Go to Websites & Domains
  3. Click the Add Domain button

Step 2: Select Laravel Site

  1. From the list of available options, select Laravel site
  2. You'll see a Laravel-specific setup screen

Step 3: Configure Domain Settings

Fill in the following information:

Domain name:

  • Enter your domain name (e.g., mylaravelapp.com)
  • Or subdomain (e.g., app.mydomain.com)

PHP Version:

  • Select the PHP version for your Laravel app
  • Laravel 10.x requires PHP 8.1 or higher
  • Laravel 9.x requires PHP 8.0 or higher
  • Choose the latest compatible version

Project Name:

  • Give your Laravel project a name
  • This will be used for the directory structure

Installation Method: Choose one of the following:

Option A: Create New Application

  • Creates a fresh Laravel installation
  • Best for new projects

Option B: Deploy from Git Repository

  • Enter your Git repository URL
  • Provide credentials if private repository
  • Best for existing Laravel projects

Step 4: Start Installation

  1. Click Install Application (or similar button)
  2. Plesk will automatically:
    • Install Laravel via Composer
    • Set up the directory structure
    • Configure PHP settings
    • Generate application key
    • Set proper permissions
  3. Wait for the installation to complete (1-3 minutes)

Step 5: Access Your Application

Once installation is complete:

  • You'll see a confirmation message
  • Click Open in Browser to view your Laravel app
  • You should see the default Laravel welcome page

Method 2: Upload Existing Laravel Application

If you already have a Laravel application, you can upload it to Plesk.

Step 1: Upload Application Files

Using File Manager:

  1. Go to Websites & Domains
  2. Find your domain and click Files
  3. Navigate to the document root (usually /httpdocs)
  4. Upload your Laravel application files
  5. Preserve the directory structure

Using FTP/SFTP:

  1. Connect with your FTP client
  2. Upload all Laravel files to your domain directory
  3. Don't upload .env file (you'll configure this in Plesk)

Using Git:

  1. Go to Websites & Domains
  2. Click Git
  3. Clone your repository

Step 2: Set Up Laravel in Plesk

  1. Go to Websites & Domains
  2. Click Manage Laravel Application on your domain
  3. Plesk will detect your Laravel installation

Configure Your Laravel Application

After installation, you need to configure your application properly.

Step 1: Access Laravel Dashboard

  1. Go to Websites & Domains
  2. Find your Laravel domain
  3. Click Manage Laravel Application

You'll see the Laravel management dashboard with several tabs:

  • Information - Overview and quick actions
  • Environment - Edit .env file
  • Artisan - Run Laravel Artisan commands
  • Composer - Manage PHP dependencies
  • NPM - Manage JavaScript dependencies
  • Deployment - Configure Git deployments
  • Scheduled Tasks - View Laravel scheduled jobs
  • Logs - View application logs

Step 2: Create and Configure Database

Laravel applications typically need a database.

Create Database

  1. From the Laravel Information dashboard, click Manage domain
  2. Click Databases
  3. Click Add Database
  4. Enter database details:
    • Database name: e.g., myapp_db
    • Database user: e.g., myapp_user
    • Password: Create a strong password
  5. Click OK

Remember these credentials - you'll need them for the next step.

Step 3: Configure Environment Variables

Laravel uses the .env file for configuration. Edit it in Plesk:

  1. Go back to Manage Laravel Application
  2. Click the Environment tab
  3. Click Edit on the .env file

Update the following values:

APP_NAME="My Laravel App"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=myapp_db
DB_USERNAME=myapp_user
DB_PASSWORD=your_database_password

Important settings:

APP_ENV:

  • Use local for development
  • Use production for live sites

APP_DEBUG:

  • Set to true for development (shows detailed errors)
  • Set to false for production (hides sensitive information)

APP_KEY:

  • Should be automatically generated
  • If missing, generate it using Artisan (see below)

Database settings:

  • Use the credentials from Step 2
  1. Click Save when done

Step 4: Generate Application Key (If Needed)

If your .env file doesn't have an APP_KEY:

  1. Go to Artisan tab
  2. Find and run the key:generate command
  3. This will add a secure key to your .env file

Step 5: Run Database Migrations

Create your database tables:

  1. Go to Artisan tab
  2. Find the migrate command
  3. Click Run
  4. Wait for migrations to complete

What this does:

  • Creates all database tables
  • Sets up the schema for your application

If you need to seed data:

  1. Run db:seed command
  2. Or run migrate:fresh --seed to reset and seed

Managing Your Laravel Application

Run Artisan Commands

Artisan is Laravel's command-line tool. In Plesk, you can run Artisan commands without SSH:

  1. Go to Artisan tab
  2. Select a command from the dropdown:
    • cache:clear - Clear application cache
    • config:cache - Cache configuration
    • route:list - List all routes
    • migrate - Run migrations
    • db:seed - Seed database
    • queue:work - Process queue jobs
    • storage:link - Create symbolic link for storage
  3. Add any parameters if needed
  4. Click Run

Custom commands:

  • Enter custom Artisan commands in the text field
  • Example: make:controller UserController

Manage Composer Dependencies

When you update your composer.json file:

  1. Go to Composer tab
  2. Select a command:
    • install - Install dependencies
    • update - Update dependencies
    • dump-autoload - Regenerate autoload files
  3. Click Run

Common use cases:

  • After pulling code updates
  • When adding new packages
  • After changing namespace

Manage NPM Dependencies

For frontend assets:

  1. Go to NPM tab
  2. Run commands:
    • npm install - Install packages
    • npm run dev - Build for development
    • npm run prod - Build for production
    • npm run build - Compile assets

View Scheduled Tasks

If your Laravel app uses task scheduling:

  1. Go to Scheduled Tasks tab
  2. View all scheduled jobs
  3. See when they run and their status

Note: The Laravel scheduler requires a cron job. Plesk usually sets this up automatically.

View Application Logs

To troubleshoot or monitor your application:

  1. Go to Logs tab (or click Logs button on domain)
  2. View Laravel application logs
  3. Filter by log level (error, warning, info)
  4. Download logs if needed

Log location:

  • Laravel logs are typically in storage/logs/laravel.log

Deploy from Git Repository

Keep your Laravel application updated with Git.

Step 1: Configure Deployment

  1. Go to Deployment tab
  2. Enter your Git repository URL
  3. If private repository:
    • Add SSH key or
    • Enter username/password
  4. Select branch (usually main or master)

Step 2: Configure Deployment Script

Plesk will run these commands after pulling code:

Default deployment script:

composer install --no-dev
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache

You can customize this script:

  1. Click Edit Deployment Script
  2. Add or modify commands
  3. Click Save

Common additions:

npm install
npm run prod
php artisan queue:restart

Step 3: Deploy Updates

To update your application:

  1. Click Update button
  2. Plesk will:
    • Pull latest code from Git
    • Run Composer install
    • Run migrations
    • Clear and cache configs
  3. View deployment logs to verify success

Automatic deployments:

  • Configure webhooks in your Git provider
  • Plesk can auto-deploy on Git push

Optimize Your Laravel Application

Cache Configuration for Production

  1. Go to Artisan tab
  2. Run these commands in order:
    • config:cache - Cache configuration files
    • route:cache - Cache routes
    • view:cache - Cache Blade views
    • event:cache - Cache events

When to cache:

  • After deploying to production
  • After changing config files
  • For better performance

Clear cache when:

  • After code changes
  • If seeing stale data
  • During development

If your app uses public storage:

  1. Go to Artisan tab
  2. Run storage:link command
  3. This creates a symbolic link from public/storage to storage/app/public

Queue Workers

If using Laravel queues:

  1. Set up queue workers in Plesk
  2. Run queue:work command
  3. Configure supervisor or use Plesk's process manager

Secure Your Laravel Application

Enable SSL Certificate

  1. Go to Websites & Domains
  2. Find your domain
  3. Click SSL/TLS Certificates
  4. Install Let's Encrypt certificate (free)
  5. Enable Redirect from HTTP to HTTPS

Security Best Practices

Production .env settings:

APP_ENV=production
APP_DEBUG=false

File permissions:

  • Plesk sets these automatically
  • Storage and cache folders should be writable

Hide sensitive files:

  • .env file should not be publicly accessible
  • Plesk configures this automatically

Troubleshooting

White Screen or 500 Error

Solutions:

  1. Check Logs tab for error details
  2. Verify .env file is configured correctly
  3. Run php artisan config:clear
  4. Check file permissions
  5. Enable debug temporarily: APP_DEBUG=true

Database Connection Error

Solutions:

  1. Verify database credentials in .env
  2. Check database exists
  3. Test database connection in Plesk
  4. Verify DB_HOST is localhost

Page Not Found (404) for Routes

Solutions:

  1. Check .htaccess file exists in public/
  2. Run php artisan route:cache
  3. Clear route cache: php artisan route:clear
  4. Verify document root points to public/ folder

Changes Not Appearing

Solutions:

  1. Clear caches:
    • php artisan cache:clear
    • php artisan config:clear
    • php artisan view:clear
  2. Restart application
  3. Clear browser cache

Composer/NPM Commands Fail

Solutions:

  1. Check PHP version compatibility
  2. Verify Composer is installed
  3. Check for syntax errors in composer.json
  4. Try running with --no-scripts flag

Best Practices

Development vs Production

Development:

APP_ENV=local
APP_DEBUG=true
  • More verbose errors
  • Hot reload for changes
  • Detailed logging

Production:

APP_ENV=production
APP_DEBUG=false
  • Cache configurations
  • Hide error details
  • Minimal logging

Regular Maintenance

  1. Update dependencies regularly:
    • Run composer update periodically
    • Test in staging first
  2. Monitor logs:
    • Check error logs daily
    • Set up log rotation
  3. Backup database:
    • Use Plesk backup tools
    • Schedule automatic backups
  4. Keep Laravel updated:
    • Follow Laravel upgrade guides
    • Test in development first

Performance Tips

  1. Use caching:
    • Cache configs, routes, and views
    • Use Redis for session/cache
  2. Optimize database:
    • Use indexes
    • Optimize queries with eager loading
  3. Use queue for heavy tasks:
    • Email sending
    • Image processing
    • API calls

Summary

To host a Laravel application on Plesk:

  1. Create Laravel site from Add Domain menu
  2. Configure database and update .env file
  3. Run migrations using Artisan commands
  4. Deploy from Git (optional) for easy updates
  5. Cache configs for production performance
  6. Enable SSL for security
  7. Monitor logs for issues

Your Laravel application is now live and ready to use!

Additional Features

  • Laravel Horizon - Monitor queues (install separately)
  • Laravel Telescope - Debug tool (development only)
  • Task Scheduler - Automatic via Plesk cron
  • Multiple apps - Host multiple Laravel apps on one server

Laravel Toolkit makes hosting Laravel applications simple and efficient!

Join our Discord community server

For any questions, suggestions, or just to chat with the community, join us on Discord!

900+Members