How to Deploy Laravel 13 on cPanel: A Complete Production Setup Guide
Author: Damodar Bhattarai — Laravel developer, Kathmandu, Nepal
This draft explains a practical, repeatable approach for deploying a Laravel 13 application to a cPanel-hosted environment. It focuses on production-ready settings: correct document root, permissions, PHP configuration, background processes, and an automated deployment workflow. Where facts may vary between hosting providers or Laravel minor versions I have marked them for editorial verification.
Quick overview
High-level steps you'll follow:
Prepare your app for production locally (environment variables, dependencies, build assets).
Provision the cPanel account: PHP version & extensions, SSH access, database, and SSL.
Upload application code (Git, SFTP, or cPanel Git Deploy).
Point the domain document root to the Laravel
publicfolder and configure.htaccess.Set correct file permissions for
storageandbootstrap/cache.Run migrations, seeders, and cache optimizations via CLI.
Configure scheduled tasks and queue workers (options explained for shared and VPS hosts).
Prerequisites
A Laravel 13 application ready to deploy locally.
cPanel access to the target hosting account with one of:
SSH access (recommended), or
SFTP access and the cPanel File Manager.
Ability to create a MySQL database and SSL certificate in cPanel.
Composer available either on the server (via SSH) or locally so you can upload the
vendor/folder.
Note: Some cPanel/shared hosts do not allow long-running processes or Supervisor. If you need queue workers or WebSocket servers, confirm your host supports them or plan on a separate worker host.
1) Prepare your application locally
Create an optimized production build locally where possible:
# Install dependencies and build front-end assets locally
composer install --no-dev --optimize-autoloader
npm ci && npm run build # or your front-end build commands
Set production environment values in
.env.production(do not commit secrets). You will copy these values on the server or use cPanel environment variables if supported.Consider enabling the following artisan optimizations before or after deployment (see notes about when to run each step):
php artisan config:cache
php artisan route:cache
php artisan view:cache
Note: Running caches before the environment file is set on the server can cause problems. Usually you run these after the .env is in place on the server.
2) cPanel setup: PHP version & extensions
In cPanel (MultiPHP Manager / Select PHP Version), set the PHP version to the one recommended for Laravel 13. Typical PHP extensions Laravel requires include: BCMath, Ctype, Fileinfo, JSON, Mbstring, OpenSSL, PDO, Tokenizer, XML, and Zip.
If the server provides an "Extensions" UI (Select PHP Version), make sure the required extensions are enabled.
3) Uploading your code
Options:
Git deployment (cPanel has a Git Version Control feature) — suitable when you push from your repo.
SSH + git pull — if the host gives SSH shell access.
SFTP or the File Manager — upload a compressed archive and extract on the server.
Upload the vendor/ directory if Composer is not available on the server.
Recommended approach for reproducibility: use Git (or deploy scripts). If Composer is not available on the host, run composer install locally with --no-dev and upload the vendor/ directory. Also ensure node built assets are uploaded.
4) Document root and the public folder
cPanel usually serves from the domain's document root (e.g., public_html or an addon domain folder). A Laravel app must serve the public directory as the web root.
Options to set the web root correctly:
Place the entire Laravel project one level above
public_htmland point the domain's document root toproject/publicusing the cPanel Domains or Addon Domains settings. (If you cannot change the web root, see the alternative below.)Alternative: move the contents of Laravel's
publicintopublic_htmland keep the rest of the app outside the web root. If you do this, updateindex.phppaths to the correct location. This approach increases risk and requires careful attention to path references.
When editing public/index.php, verify these lines that reference the application bootstrap are correct for your folder layout:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
Adjust relative paths if you relocated files. Any path changes should be tested immediately.
5) .htaccess for pretty URLs
Laravel's default public/.htaccess should work with Apache on cPanel. Typical content (verify against your framework version):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
If you need custom rules (for subdirectory deployment or asset caching) adapt the file carefully.
6) File and folder permissions
Make sure the web server can write to the following directories:
storage
bootstrap/cache
Recommended minimal approach:
# from project root on the server
chmod -R 755 storage
chmod -R 755 bootstrap/cache
# If writable by the web server user is required:
chown -R <username>:<web-server-group> storage bootstrap/cache # requires shell access
On many shared hosts chown is not available; use 755/775 as allowed and consult host docs. Never set 0777 permissions if you can avoid it.
7) Environment (.env) and database configuration
Create a MySQL database and user via cPanel > MySQL Databases.
Copy database credentials into the server
.envfile (use the server file manager or SSH editor). Keep.envout of version control.If cPanel supports environment variables via the UI (some hosts provide this), consider using that instead of an
.envfile for extra safety.
8) Composer on the server vs local install
If you have SSH and Composer installed on the server:
# in project directory on server
composer install --no-dev --optimize-autoloader
php artisan key:generate # if you do not have APP_KEY set
php artisan migrate --force
If Composer is not available, run composer locally and upload the vendor directory. Be careful with platform-specific binaries/extensions. Use composer install --no-dev --optimize-autoloader --prefer-dist locally and sync the vendor folder.
9) Migrations, keys, and cache
Ensure
APP_KEYis set in.env. If missing, runphp artisan key:generate(preferably via SSH).Run migrations on the server with
php artisan migrate --force(the--forceflag is required to run in production).Run caches after environment is in place:
php artisan config:cache
php artisan route:cache
php artisan view:cache
Note: If you use environment-driven configuration (like queue connections stored in .env), ensure the .env is final before running config:cache.
10) Scheduler and queues on cPanel
Scheduler (cron):
Add a cron job in cPanel to run Laravel's scheduler every minute:
* * * * * /usr/local/bin/php /home/username/path-to-project/artisan schedule:run >> /dev/null 2>&1
Replace /usr/local/bin/php and the path with the server-specific PHP binary path and project path. To find the PHP CLI path, check with your host or ask support.
Queue workers:
On VPS or dedicated servers: use Supervisor to run
php artisan queue:workas a persistent worker.On shared cPanel hosting (where Supervisor is not available): consider one of these options:
Use a cron job to periodically run
php artisan queue:work --onceto process jobs in short bursts.Use a third-party queue worker host or managed service to process jobs.
Example cron to process queue jobs every minute (not equivalent to a persistent worker but workable on shared hosts):
* * * * * /usr/local/bin/php /home/username/path-to-project/artisan queue:work --once --queue=default >> /dev/null 2>&1
Note: The exact best approach depends on your job latency requirements and host capabilities. If persistent workers are needed, plan on a VPS or a separate worker service.
11) SSL / HTTPS
Enable AutoSSL or install a Let's Encrypt certificate via cPanel > SSL/TLS. Then configure a redirect to force HTTPS in .htaccess or in your application middleware.
Example .htaccess redirect to HTTPS (verify rules with your server):
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Also set SESSION_SECURE_COOKIE=true and SESSION_DOMAIN appropriately in your .env for production.
12) Zero-downtime deployment checklist
For small sites, a basic maintenance mode is sufficient. Laravel provides maintenance mode to take the app offline while you deploy:
php artisan down
# deploy changes, run migrations
php artisan up
For higher-availability needs consider a deployment strategy with atomic symlink swaps or use a CI/CD tool that deploys to a staging folder then swaps folders. Some of these approaches require SSH and scripting privileges on the host.
13) Common troubleshooting tips
Blank page or 500 error: check server error logs in cPanel > Metrics > Errors and Laravel logs in
storage/logs.Missing vendor classes: ensure
vendor/is present or Composer ran successfully.Permission denied for storage or cache: review file permissions and ownership.
Command not found for
phpin cron: use the full path to the PHP CLI binary (ask host for correct path).
14) Final checklist before going live
.env configured and not committed to VCS
APP_KEY set
Database credentials configured and migrations run
Storage and bootstrap/cache permissions set
Document root points to
publicSSL is enabled and HTTP redirects to HTTPS
Scheduler cron job added
Queue strategy defined and operational
Caches regenerated after deploy (config, routes, views)
Notes and verifications
This guide assumes many Laravel commands and cPanel UI elements are available and behave as described. Please verify Laravel 13 specific command behavior and the exact PHP extension requirements for Laravel 13.
Hosting providers differ in available features (SSH, Composer, Supervisor). Confirm limits with your host before relying on long-running processes.
Closing
This guide is intended as a practical checklist and set of patterns to deploy Laravel applications to cPanel. The safest and most repeatable deployments use SSH, Composer on the server, and an automated CI/CD pipeline; if your cPanel host limits you, use local builds and careful file uploads plus cron-based workarounds for background jobs.
If you want, I can convert these steps into a deploy script that runs from SSH (if your host permits), or provide a concise checklist PDF for your operations team.