keepcalculator

06 Numbers and Powers

Hosting for Laravel: What You Need to Know

Card No. 06·64421 · Updated · Standard formula, shown below

Hosting for Laravel means choosing a server that can run PHP 8.1+ and Composer, and that gives you control over the document root, environment variables, and queue workers. This article explains what Laravel specifically requires from a host, how to pick between shared, VPS, and platform-as-a-service options, and how to avoid the most common deployment pitfalls.

What Laravel Actually Needs from a Host

Laravel is a PHP framework with specific server requirements. The official documentation states that Laravel requires PHP 8.1 or higher (as of Laravel 10 and 11) with several extensions: OpenSSL, PDO, Mbstring, Tokenizer, XML, Ctype, JSON, BCMath, and Fileinfo. Most modern hosts include these by default, but some shared hosts still run older PHP versions, so check before you buy.

Beyond PHP, Laravel needs a web server (Apache or Nginx) configured to point the document root to the public folder, not the project root. It also needs Composer to install dependencies, and a database (MySQL, PostgreSQL, SQLite, or SQL Server). For production, you also want a queue worker (like Redis or a database queue) and a cron job for the scheduler.

Shared Hosting: Can It Run Laravel?

Yes, but with caveats. Many shared hosts now offer PHP 8.x and Composer via SSH, and some have one-click Laravel installers. However, shared hosting typically gives you limited control over the server environment, which can cause problems:

  • Document root is often fixed to public_html, so you must either symlink or move Laravel’s public files.
  • Queue workers and cron jobs may be restricted or require manual setup.
  • Environment variables (.env) are usually fine, but some hosts block certain PHP functions.

If you choose shared hosting, look for a provider that explicitly supports Laravel, offers SSH access, and lets you set the PHP version. SiteGround and Hostinger are examples (not an endorsement) that advertise Laravel support, but always verify current features.

VPS and Dedicated Servers: Full Control

A Virtual Private Server (VPS) or dedicated server gives you root access, so you can install exactly what Laravel needs. This is the most flexible option and is what most production Laravel apps use. With a VPS you can:

  • Install Nginx or Apache and configure the document root.
  • Set up PHP-FPM and adjust memory limits.
  • Run queue workers as system services (e.g., Supervisor).
  • Install Redis, Memcached, or other caching engines.

The downside is that you are responsible for server maintenance, security updates, and scaling. For a small project, a managed VPS from providers like DigitalOcean or Linode (again, examples) can be a good balance of control and convenience.

Platform as a Service (PaaS): Laravel Forge, Vapor, and Others

PaaS solutions abstract away server management. Laravel Forge is a server management tool that provisions and configures servers on providers like AWS, DigitalOcean, and Linode. It handles Nginx, PHP, queues, and cron jobs for you. Laravel Vapor is a serverless deployment platform for Laravel, running on AWS Lambda, which scales automatically and charges per request.

Other PaaS options include Heroku (though its free tier is gone) and Platform.sh. These are great if you want to focus on code rather than server admin, but they can be more expensive at scale and may lock you into a specific workflow.

How to Choose: A Decision Guide

Your choice depends on your budget, technical comfort, and project size. Here is a simple framework:

  • Learning or small demo: Shared hosting with Laravel support, or a local environment like Laravel Herd.
  • Small production app: A managed VPS (e.g., via Laravel Forge) or a PaaS like Platform.sh.
  • High-traffic or scaling needs: Laravel Vapor (serverless) or a dedicated server with load balancing.
  • Enterprise: Cloud providers (AWS, GCP, Azure) with Kubernetes or Elastic Beanstalk.

Also consider the database: if you expect high traffic, a separate database server is better than co-locating on the same VPS.

Common Problems and How to Avoid Them

Even with good hosting, Laravel deployment has classic pitfalls:

  • Wrong document root: If you upload the whole project to public_html, visitors may see the directory listing or a 500 error. Always point the web root to the public folder.
  • Missing Composer dependencies: Run composer install --no-dev on the server, not just on your local machine.
  • Permission errors: The storage and bootstrap/cache directories must be writable by the web server user.
  • Environment config: Make sure .env is set correctly, especially APP_KEY. Run php artisan key:generate if needed.
  • Queues not running: If you use queues for email or jobs, you must start a worker. On shared hosting, this may be impossible; on VPS, use Supervisor.
  • Cache not cleared: After deploying changes, run php artisan config:cache and route:cache to avoid stale config.

Costs: What to Expect

Prices vary widely by region and provider, but general ranges (as of 2024) are:

  • Shared hosting with Laravel support: $5–$15 per month.
  • Managed VPS (e.g., via Forge): $10–$50 per month for the server, plus Forge’s fee (around $19/month).
  • Unmanaged VPS: $5–$20 per month, but you do the setup.
  • Laravel Vapor: pay-as-you-go, typically starts around $39/month for the platform fee plus AWS costs.

These are estimates, not guarantees. Always check current pricing on the provider’s site.

Frequently Asked Questions

Can I run Laravel on shared hosting?

Yes, but only if the host supports PHP 8.1+, Composer, and allows you to change the document root. Some shared hosts have specific Laravel installers. Be prepared to handle permissions and possibly use a workaround for queues.

Do I need a VPS for Laravel?

Not necessarily. For learning or small traffic, shared hosting is fine. For production with real users, a VPS gives you the control and reliability you need, especially for queues and scheduled tasks.

What is the difference between Laravel Forge and Laravel Vapor?

Forge manages traditional servers (VPS) by configuring Nginx, PHP, and queues. Vapor is a serverless platform that runs Laravel on AWS Lambda, so you don’t manage servers at all—you pay per request and scale automatically.

How do I deploy a Laravel app to a VPS?

Typical steps: set up a server with PHP and Composer, clone your repository, run composer install, copy .env, set permissions on storage, configure Nginx to point to the public folder, and restart PHP-FPM. Use a tool like Envoy or Forge to automate it.

Is Laravel hosting different from regular PHP hosting?

Yes, because Laravel has specific requirements like the public folder structure, Composer, and often queues. Regular PHP hosting may not support these out of the box, so you need a host that explicitly supports Laravel or a VPS.

Can I use free hosting for Laravel?

Some free tiers exist (e.g., certain PaaS providers), but they often have limitations like sleep times, restricted storage, or no cron jobs. For production, free hosting is generally not recommended.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →