Deployment

    Server Requirements

    The Laravel framework has a few system requirements. You should ensure that your web server has the following minimum PHP version and extensions:

    • PHP >= 8.1
    • cURL PHP Extension
    • DOM PHP Extension
    • Fileinfo PHP Extension
    • Filter PHP Extension
    • Hash PHP Extension
    • Mbstring PHP Extension
    • OpenSSL PHP Extension
    • PCRE PHP Extension
    • PDO PHP Extension
    • Session PHP Extension
    • Tokenizer PHP Extension
    • XML PHP Extension

    If you are deploying your application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server’s configuration. If you would like assistance in managing your server, consider using a first-party Laravel server management and deployment service such as .

    Please ensure, like the configuration below, your web server directs all requests to your application’s file. You should never attempt to move the index.php file to your project’s root, as serving the application from the project root will expose many sensitive configuration files to the public Internet:

    Optimization

    When deploying to production, make sure that you are optimizing Composer’s class autoloader map so Composer can quickly find the proper file to load for a given class:

    This command will combine all of Laravel’s configuration files into a single, cached file, which greatly reduces the number of trips the framework must make to the filesystem when loading your configuration values.

    If you are building a large application with many routes, you should make sure that you are running the route:cache Artisan command during your deployment process:

    This command reduces all of your route registrations into a single method call within a cached file, improving the performance of route registration when registering hundreds of routes.

    When deploying your application to production, you should make sure that you run the Artisan command during your deployment process:

    The debug option in your config/app.php configuration file determines how much information about an error is actually displayed to the user. By default, this option is set to respect the value of the APP_DEBUG environment variable, which is stored in your application’s .env file.

    In your production environment, this value should always be false. If the APP_DEBUG variable is set to true in production, you risk exposing sensitive configuration values to your application’s end users.

    Deploying With Forge / Vapor

    Laravel Forge

    If you aren’t quite ready to manage your own server configuration or aren’t comfortable configuring all of the various services needed to run a robust Laravel application, Laravel Forge is a wonderful alternative.

    Laravel Forge can create servers on various infrastructure providers such as DigitalOcean, Linode, AWS, and more. In addition, Forge installs and manages all of the tools needed to build robust Laravel applications, such as Nginx, MySQL, Redis, Memcached, Beanstalk, and more.

    Laravel Vapor