UnderHost
Knowledgebase Docs

Deploy Laravel on UnderHost VPS and Shared Hosting

Deploy Laravel web applications on UnderHost shared hosting or VPS. Configure environment, database, Artisan commands, and production optimization.

On this page

Laravel is the most popular PHP framework for building modern web applications. It includes everything: routing, ORM (Eloquent), s, authentication, queuing. Whether on UnderHost shared hosting or VPS, Laravel deployment involves the same fundamental steps.

Requirements

  • UnderHost Hosting (shared hosting or VPS)
  • PHP 8.0+ (check your hosting control panel)
  • Composer for dependency management
  • MySQL or MariaDB for database
  • SSH access (VPS) or FTP (shared hosting)

Upload Laravel Project

Option 1: Via SSH/Git (VPS/Dedicated):

cd /home/username/public_html
git clone https://github.com/yourname/myapp.git
cd myapp

Option 2: Via FTP (Shared Hosting):

  1. Download your Laravel project on your computer
  2. Connect via FTP (FileZilla, WinSCP)
  3. Upload to public_html folder

Install Dependencies (Composer)

Check if Composer is installed:

composer --version

If not installed, get Composer and install dependencies:

cd /home/username/public_html/myapp
composer install

This reads composer.json and installs all Laravel dependencies into vendor/ folder.

Environment Configuration

Copy example environment file:

cp .env.example .env

Generate application key:

php artisan key:generate

Edit .env with your database credentials:

APP_NAME=MyApp
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=username_myapp
DB_USERNAME=username_user
DB_PASSWORD=your_strong_password

Database Setup

In cPanel (Shared Hosting):

  1. Create MySQL database: username_myapp
  2. Create user with password
  3. Grant all permissions to user on database

Run Laravel s:

php artisan migrate

This creates database tables from your files.

File Permissions

Laravel storage directories need write access:

# Via SSH
chmod -R 775 storage bootstrap/cache

# Via FTP or File Manager
Set permissions to 755 for storage/ and bootstrap/cache/

Shared Hosting vs VPS

AspectShared HostingVPS
DeploymentFTP + cPanel → easyGit clone or SFTP → more control
ComposerMay need to upload vendor/ folder via FTPRun composer install on server
Artisan CommandsMay not work directly; contact supportFull SSH access: php artisan migrate
Queue JobsNot available (no background tasks)Use Redis + Supervisor for queues
SSL/HTTPSAuto-renewing Let's Encrypt in cPanelManual or aaPanel/CloudPanel auto SSL

Production Optimization

Cache configuration and routes:

php artisan config:cache
php artisan route:cache
php artisan view:cache

Set proper APP_DEBUG and error handling:

# .env
APP_DEBUG=false
LOG_CHANNEL=single

Use queue jobs for long tasks (VPS only):

# queue:listen runs on VPS, processes background jobs
php artisan queue:listen

Enable lazy loading protection:

# config/database.php
'postgresql' => [
    // ...
    'strict' => true,
],
One-click deploy available

Many hosting providers (including some UnderHost VPS plans with aaPanel/CloudPanel) support one-click Laravel deployment. Check your control panel's app marketplace.

Related: PHP deployment | Composer package manager | Laravel optimization tips

Was this article helpful?

Need a developer-friendly server?

Use an UnderHost Cloud VPS for SSH, Git, Node.js, Python, Laravel, Docker, cron, and custom development workflows.

Back to Developer Tools