Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sanukdev's avatar

Local Development to Production Deployment

Pretty new to all of this. I have completed several series and have always followed along. I have a super minor website I want to deploy out there to the real world. Either I can't find it or it doesn't exist as of yet, but there seems to be no series or discussion talking about how to go fully from a local development to a production deployment. Several series bookend both of those topics but there seems to be a small bit missing. How do I compile it for deployment? What variables in the .env file to I need to change? What else do I need to do? I plan on using Forge to manage it with Digital Ocean.

0 likes
2 replies
LaryAI's avatar
Level 58

Deploying a Laravel application from local development to production involves several steps. Below is a comprehensive guide to help you through the process, especially if you plan to use Laravel Forge and Digital Ocean.

Step 1: Prepare Your Local Environment

  1. Ensure Your Code is Ready for Production:

    • Make sure your code is clean and tested.
    • Remove any debug code or unnecessary files.
  2. Update Your .env File:

    • Ensure your .env file is configured correctly for production. For example:
      APP_ENV=production
      APP_DEBUG=false
      APP_URL=https://yourdomain.com
      

Step 2: Push Your Code to a Version Control System

  1. Initialize a Git Repository:

    • If you haven't already, initialize a Git repository in your project directory:
      git init
      
  2. Commit Your Changes:

    • Add and commit your changes:
      git add .
      git commit -m "Initial commit"
      
  3. Push to a Remote Repository:

    • Push your code to a remote repository like GitHub, GitLab, or Bitbucket:
      git remote add origin https://github.com/yourusername/yourrepository.git
      git push -u origin master
      

Step 3: Set Up Your Server with Laravel Forge

  1. Create a New Server:

    • Log in to Laravel Forge and create a new server. Choose Digital Ocean as your provider and configure the server settings.
  2. Deploy Your Site:

    • Once the server is ready, create a new site on the server. Forge will ask for your Git repository URL and branch to deploy.
  3. Configure Environment Variables:

    • In Forge, go to the "Environment" tab of your site and set the necessary environment variables. This will replace the .env file in your local environment. For example:
      APP_ENV=production
      APP_DEBUG=false
      APP_URL=https://yourdomain.com
      DB_CONNECTION=mysql
      DB_HOST=127.0.0.1
      DB_PORT=3306
      DB_DATABASE=yourdatabase
      DB_USERNAME=yourusername
      DB_PASSWORD=yourpassword
      

Step 4: Deploy Your Application

  1. Deploy the Code:

    • In Forge, click the "Deploy" button to deploy your code to the server.
  2. Run Migrations and Seeders:

    • After deployment, you may need to run database migrations and seeders:
      php artisan migrate --force
      php artisan db:seed --force
      
  3. Set Up Storage and Cache:

    • Ensure the storage and cache directories are writable:
      php artisan storage:link
      php artisan config:cache
      php artisan route:cache
      php artisan view:cache
      

Step 5: Configure Your Domain

  1. Point Your Domain to the Server:

    • Update your DNS settings to point your domain to the IP address of your Digital Ocean server.
  2. Set Up SSL:

    • In Forge, you can easily set up an SSL certificate using Let's Encrypt. Go to the "SSL" tab of your site and follow the instructions.

Step 6: Monitor and Maintain

  1. Monitor Your Application:

    • Use tools like Laravel Telescope, Sentry, or New Relic to monitor your application for errors and performance issues.
  2. Regular Backups:

    • Set up regular backups for your database and important files.

By following these steps, you should be able to successfully deploy your Laravel application from local development to a production environment using Laravel Forge and Digital Ocean.

1 like
jlrdw's avatar

but there seems to be no series or discussion talking about how to go fully from a local development to a production deployment.

Each host is a little different.

Each host has guides, for example Digital Ocean has a wealth of how to articles.

Many shared host has articles.

The main thing is point to public as document root.

Please or to participate in this conversation.