Skip to main content

Introduction

When you deploy a Laravel application to production, you need to prepare it to run as efficiently as possible. This guide walks through the key points for reliable production deployment.

Deployment flow

Server requirements

The Laravel framework has the following system requirements. PHP 8.3 or higher and the PHP extensions listed below are required.

Server configuration

Nginx

If you’re using Nginx, base your configuration on the file below. It’s important to forward all requests to public/index.php. Do not move index.php to the project root—this would expose sensitive configuration files.

FrankenPHP

FrankenPHP is a modern PHP application server written in Go. You can start a Laravel application with a single command:
For advanced features such as HTTP/3, modern compression, Laravel Octane integration, and standalone binaries, see FrankenPHP’s Laravel documentation.

Directory permissions

Laravel needs to write to the bootstrap/cache and storage directories. Set permissions so the web server’s process owner can write to these directories.

Optimization

When deploying to production, cache configuration, events, routes, and views to improve performance. The optimize command performs all caches at once.
To clear caches, use optimize:clear.

Individual optimization commands

optimize runs the following commands together. You can also run them individually as needed.
After running config:cache, only call the env() function inside configuration files. Once cached, the .env file is no longer loaded, so calling env() outside configuration files returns null.

Reloading services

After you deploy a new version, long-running services such as queue workers, Laravel Reverb, and Laravel Octane need to be restarted to pick up the new code.
This command shuts down reloadable services. Set up a process monitor (such as Supervisor) to automatically restart them.
When using Laravel Cloud, graceful reloading of all services is handled automatically, so you do not need to run the reload command.

Debug mode

The debug option in config/app.php controls how much error information is shown to the user. By default, it uses the value of the APP_DEBUG environment variable in the .env file.
In production, always set APP_DEBUG to false. Running with APP_DEBUG=true in production risks exposing sensitive configuration values such as database credentials and secret keys to end users.

Health check route

Laravel includes a built-in health check route for monitoring your application’s status. It can integrate with uptime monitors, load balancers, and orchestration systems like Kubernetes. By default, an /up endpoint is provided. It returns 200 if the application has started successfully, or 500 if an exception occurred during startup. You can customize the URI in bootstrap/app.php.
When a request hits this route, the Illuminate\Foundation\Events\DiagnosingHealth event is dispatched, so you can implement additional checks for the database, cache, and so on in listeners.

Deploying with Laravel Cloud or Forge

Laravel Cloud

If you’re looking for a fully managed, auto-scaling deployment platform, Laravel Cloud is a great choice. It’s a PaaS optimized for Laravel that provides managed compute, database, cache, and object storage. The Laravel core team tunes it directly, and it integrates seamlessly with the framework.

Laravel Forge

If you want to manage your own servers but don’t want to spend time setting up Nginx, MySQL, and other services, Laravel Forge is a great option. It creates servers on major cloud providers such as DigitalOcean, Linode, and AWS, and automatically installs and manages tools like Nginx, MySQL, Redis, Memcached, and Beanstalk.

Next steps

Deployment — Official documentation

See the official documentation for the latest deployment configuration details.
Last modified on July 13, 2026