Skip to content
Free website migration on every plan, done by our team.Learn more ›
Servers

How to host a Laravel app on cPanel or a VPS

Deploy Laravel properly: PHP version and extensions, pointing the domain to /public, .env and permissions, the scheduler, and when you need a VPS.

Short answer: Laravel runs on cPanel hosting if the plan offers a recent PHP version, SSH or Composer access, and lets you point your domain at the app's public folder. Choose a VPS when you need queue workers running all the time, WebSockets, Redis or full control of the server.

Laravel is one of the most popular PHP frameworks, and deploying it is straightforward once you know its few special requirements. Here's how to do it on shared hosting and on a VPS.

What Laravel needs

  • PHP 8.2 or newer for Laravel 11 and 12 (check the documentation for your version) (which PHP version)
  • PHP extensions including BCMath, Ctype, cURL, DOM, Fileinfo, Mbstring, OpenSSL, PDO, Tokenizer and XML
  • A MySQL or MariaDB database
  • Composer, and ideally SSH access

Option 1: cPanel hosting

  1. Choose the PHP version in cPanel's PHP selector and enable the extensions above.
  2. Upload the code outside public_html, for example to a folder called myapp, using Git or SSH (how to use SSH).
  3. Point the domain at the public folder. In cPanel's Domains page, set the document root to myapp/public. Only that folder should be reachable from the web, so your .env file stays private.
  4. Install and configure from the app folder:
composer install --no-dev --optimize-autoloader
cp .env.example .env
php artisan key:generate
php artisan migrate --force
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache

Put your database name, user and password in .env before running the migration.

  1. Make storage and bootstrap/cache writable by your account.
  2. Add the scheduler as a cron job that runs every minute (cron jobs explained):
* * * * * cd ~/myapp && php artisan schedule:run >> /dev/null 2>&1
  1. Queues on shared hosting: use the database queue driver and process jobs from the scheduler with queue:work and the --stop-when-empty option. Workers that run all the time need a VPS.

Option 2: a VPS

A VPS gives you a full Laravel stack: Nginx with PHP-FPM, Supervisor to keep queue workers running, Redis for cache and queues, and free Let's Encrypt SSL. The key part of the Nginx configuration points the site at the public folder:

root /var/www/myapp/public;
index index.php;
location / { try_files $uri $uri/ /index.php?$query_string; }

Start with your first steps on a new VPS and the Nginx reverse proxy guide. AuroxHost cloud VPS plans start at $5.00 a month with full root access.

Common problems

  • 500 error right after upload: usually a missing .env or APP_KEY, or folders that aren't writable (fix a 500 error)
  • "The stream or file could not be opened": storage folder permissions
  • Missing CSS and JavaScript: run npm run build before deploying and upload the public/build folder

Frequently asked questions

Can I host Laravel on shared hosting?

Yes, for most small and medium apps, as long as you can choose PHP 8.2 or newer, run Composer and point the domain at the public folder. Always-on queue workers and WebSockets need a VPS.

Why does my Laravel site show a 500 error after uploading?

The usual causes are a missing .env file or APP_KEY, storage and bootstrap/cache folders that aren't writable, or a PHP version that's too old. Check storage/logs/laravel.log for the exact error.

Should I upload the vendor folder?

It's better to run composer install on the server, so packages match its PHP version. If you can't run Composer there, build locally with the same PHP version and upload vendor.

Ready when you are

Host it where it performs

NVMe speed, offshore privacy and a written SLA — live in minutes on AuroxHost.