azimidev's avatar

We need more DevOps Lessons

Hi @jeffreyway

First of all, massive thanks for all the amazing content - Laracasts has been my go-to for years. I was wondering if you’d consider adding a series focused more on DevOps for Laravel developers - especially covering real-world infrastructure topics from chosen teachers like:

  • Deploying Laravel to AWS EC2
  • Using Docker in production and local environments
  • Configuring CloudFront for assets and CDN delivery
  • Managing environment variables/secrets across environments
  • Automating deployment with Ansible or GitHub Actions
  • Setting up CI/CD pipelines with testing and staging
  • Caching strategies, queue optimization, and scaling tips
  • Using ECS, S3, RDS, and other AWS services efficiently

There’s a huge gap between finishing a Laravel project and deploying/running it like a pro — and I think a lot of us would love to level up our DevOps game directly from you.

Appreciate your time - and thanks again for everything you already do 🙌

0 likes
3 replies
LaryAI's avatar

Absolutely, this is a fantastic suggestion and a common pain point for many Laravel developers transitioning from local development to real-world deployment and scaling. While Laracasts has some deployment and server management content, a dedicated DevOps series tailored for Laravel would be incredibly valuable.

Here’s a brief outline and some resources to get you started on these topics right now:


1. Deploying Laravel to AWS EC2

  • Steps:

    1. Launch an EC2 instance (Ubuntu is common).
    2. SSH into your server and install PHP, Composer, Nginx/Apache, and MySQL/PostgreSQL.
    3. Clone your Laravel project and set up your .env file.
    4. Set correct permissions for storage and bootstrap/cache.
    5. Configure your web server to serve the public directory.
  • Example Nginx config:

    server {
        listen 80;
        server_name your_domain.com;
        root /var/www/your_project/public;
    
        index index.php index.html;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    

2. Using Docker in Production and Local Environments

  • Tools: Laravel Sail, Laradock, or custom Dockerfiles.
  • Example docker-compose.yml:
    version: '3.8'
    services:
      app:
        build:
          context: .
          dockerfile: Dockerfile
        volumes:
          - .:/var/www/html
        ports:
          - "8000:80"
        environment:
          - APP_ENV=local
    

3. Configuring CloudFront for Assets and CDN Delivery

  • Upload assets (images, CSS, JS) to S3.
  • Set up a CloudFront distribution with the S3 bucket as the origin.
  • Update your Laravel asset URLs to use the CloudFront domain:
    <img src="{{ asset('images/logo.png') }}">
    // becomes
    <img src="https://your-cloudfront-domain.com/images/logo.png">
    

4. Managing Environment Variables/Secrets

  • Use AWS Secrets Manager, SSM Parameter Store, or .env files (with care).
  • For CI/CD, inject secrets as environment variables rather than committing them.

5. Automating Deployment with Ansible or GitHub Actions

  • GitHub Actions Example:
    name: Deploy to Production
    
    on:
      push:
        branches: [main]
    
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
          - name: Deploy via SSH
            uses: appleboy/[email protected]
            with:
              host: ${{ secrets.HOST }}
              username: ${{ secrets.USERNAME }}
              key: ${{ secrets.SSH_KEY }}
              script: |
                cd /var/www/your_project
                git pull origin main
                composer install --no-dev --optimize-autoloader
                php artisan migrate --force
                php artisan config:cache
    

6. Setting up CI/CD Pipelines

  • Use GitHub Actions, GitLab CI, or Bitbucket Pipelines to run tests, build assets, and deploy.
  • Example: Run PHPUnit and Laravel Dusk tests on every pull request.

7. Caching Strategies, Queue Optimization, and Scaling

  • Use Redis or Memcached for cache and queue drivers.
  • Use Horizon for queue monitoring.
  • Scale horizontally by adding more EC2 instances or using ECS.

8. Using ECS, S3, RDS, and Other AWS Services

  • ECS: Containerize your app and deploy using Fargate.
  • S3: Store user uploads and static assets.
  • RDS: Managed database service for MySQL/Postgres.
  • Use IAM roles for secure access.

Further Learning:


Final Note:
If you’d like to see a full Laracasts series on these topics, consider posting in the Laracasts "Series Requests" forum or upvoting similar threads. The more interest shown, the more likely it is to happen!

Let me know if you want a deep dive into any of these topics!

jlrdw's avatar

Some stuff is here already, like https://laracasts.com/series/aws-fundamentals

https://laracasts.com/series/servers-for-laravel

etc. I suggest search first and narrow your list.

Also AWS has a ton of their own tutorials and learning material.

How about digital ocean and others? There are so many deployment scenarios I (just my opinion) can't see trying to cover them all.

Edit:

Docker also has guides, like:

https://docs.docker.com/guides/frameworks/laravel/production-setup/

Also:

https://laravel-news.com/deploy-your-php-app-with-ansible-and-github-actions

azimidev's avatar

@jlrdw appreciate the links, but my message is specifically directed at @jeffreyway. The content you shared is great for beginners, but it doesn’t go deep enough into real-world DevOps scenarios, I’m talking about managing production infrastructure at scale with Docker, ECS, Kubernetes, CI/CD, and AWS services beyond the basics. Laravel Forge covers simple cases. I’m looking for screencasts, not documentation, there’s a big difference between reading docs and watching real-world problem-solving by an expert. Hope that clarifies it.

2 likes

Please or to participate in this conversation.