← Blog · Tutorials

Laravel Livewire Deployment: The Complete Production Guide

April 17, 2026

Laravel Livewire Deployment: The Complete Production Guide

Getting your laravel + livewire deployment right is critical — Livewire adds real-time interactivity to Laravel apps, but it also introduces deployment considerations that vanilla Laravel doesn't have. From asset compilation to WebSocket configuration, there are specific steps you need to follow to ensure your Livewire components work flawlessly in production.

This guide walks you through deploying a Laravel application with Livewire to a VPS, covering every step from server setup to post-deployment verification.

Prerequisites for Laravel + Livewire Deployment

Before deploying, ensure your server meets these requirements:

  • PHP 8.2+ with required extensions (BCMath, Ctype, cURL, DOM, Fileinfo, JSON, Mbstring, OpenSSL, PDO, Tokenizer, XML)
  • Composer for dependency management
  • Node.js 18+ and npm for frontend asset compilation
  • Nginx or Apache as web server
  • MySQL 8.0+ or PostgreSQL 15+
  • Redis (recommended for caching and session management)
# Install everything on Ubuntu sudo apt update sudo apt install php8.2-fpm php8.2-mysql php8.2-redis php8.2-xml \\   php8.2-mbstring php8.2-curl php8.2-zip php8.2-bcmath \\   nginx mysql-server redis-server nodejs npm -y 

Step 1: Prepare Your Application Locally

Install Dependencies Without Dev Packages

composer install --optimize-autoloader --no-dev npm ci && npm run build 

The npm run build step is especially important for Livewire v3, which bundles its JavaScript through Vite. If you skip this, Livewire's frontend won't load in production.

Verify Livewire Configuration

Check your config/livewire.php for production-ready settings:

return [     'asset_url' => env('APP_URL'),     'app_url' => env('APP_URL'),     'middleware_group' => 'web',     'temporary_file_upload' => [         'disk' => 's3', // Use S3 or similar in production for file uploads         'rules' => ['required', 'file', 'max:12288'],     ], ]; 

Environment Configuration

Your .env must be configured correctly for production:

APP_ENV=production APP_DEBUG=false APP_URL=https://yourdomain.com  LIVEWIRE_ASSET_URL=https://yourdomain.com  SESSION_DRIVER=redis CACHE_DRIVER=redis QUEUE_CONNECTION=redis 

Setting APP_DEBUG=false is non-negotiable — debug mode in production exposes your entire configuration stack.

Step 2: Server Setup and Laravel + Livewire Deployment

Clone and Configure

cd /var/www git clone git@github.com:youruser/yourapp.git cd yourapp  # Install dependencies composer install --optimize-autoloader --no-dev npm ci && npm run build  # Configure environment cp .env.production .env php artisan key:generate  # Run migrations php artisan migrate --force  # Set permissions sudo chown -R www-data:www-data /var/www/yourapp sudo chmod -R 755 /var/www/yourapp sudo chmod -R 775 /var/www/yourapp/storage sudo chmod -R 775 /var/www/yourapp/bootstrap/cache 

Nginx Configuration for Livewire

Livewire communicates with the server via AJAX requests to a /livewire endpoint. Your Nginx config must properly proxy these requests:

server {     listen 80;     server_name yourdomain.com www.yourdomain.com;     root /var/www/yourapp/public;      add_header X-Frame-Options "SAMEORIGIN";     add_header X-Content-Type-Options "nosniff";      index index.php;     charset utf-8;      # Handle Livewire requests     location /livewire {         try_files $uri $uri/ /index.php?$query_string;     }      location / {         try_files $uri $uri/ /index.php?$query_string;     }      location = /favicon.ico { access_log off; log_not_found off; }     location = /robots.txt  { access_log off; log_not_found off; }      error_page 404 /index.php;      location ~ \\.php$ {         fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;         include fastcgi_params;                  # Increase timeouts for Livewire file uploads         fastcgi_read_timeout 300;     }      location ~ /\\.(?!well-known).* {         deny all;     } } 

SSL Setup

sudo apt install certbot python3-certbot-nginx -y sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com 

Step 3: Cache Everything

Laravel's caching commands are essential for production performance, and they directly impact Livewire's response times:

# Cache configuration php artisan config:cache  # Cache routes (includes Livewire routes) php artisan route:cache  # Cache views (includes Livewire component views) php artisan view:cache  # Cache events php artisan event:cache 

Important: After running config:cache, changes to .env require re-running the cache command. This is the #1 cause of "it works locally but not in production" issues.

Step 4: Livewire-Specific Production Considerations

File Uploads

Livewire handles file uploads through temporary storage. In production, configure a proper disk:

// config/filesystems.php 'disks' => [     'livewire-tmp' => [         'driver' => 'local',         'root' => storage_path('app/livewire-tmp'),     ], ], 

Add a cleanup cron job to prevent temporary files from accumulating:

# Clean up Livewire temp files daily at 3 AM 0 3 * * * cd /var/www/yourapp && php artisan livewire:configure-s3-upload-cleanup 

Or manually with a scheduled command in app/Console/Kernel.php:

$schedule->command('livewire:configure-s3-upload-cleanup')->daily(); 

Alpine.js and Asset Loading

Livewire v3 ships with Alpine.js bundled. Make sure you're not loading Alpine separately, or you'll get conflicts:

<!-- Don't do this if using Livewire v3 --> <!-- <script src="alpinejs.min.js"></script> -->  <!-- Livewire v3 injects Alpine automatically --> @livewireStyles <!-- ... your content ... --> @livewireScripts 

If you're using @vite, Livewire assets are injected automatically — no need for the @livewireStyles and @livewireScripts directives.

Session Configuration

Livewire relies heavily on sessions. Using file-based sessions in production can cause issues with load-balanced setups. Use Redis:

SESSION_DRIVER=redis SESSION_LIFETIME=120 SESSION_ENCRYPT=true 

Step 5: Deployment Script

Combine everything into a reusable deployment script:

#!/bin/bash set -e  cd /var/www/yourapp  echo "Pulling latest code..." git pull origin main  echo "Installing PHP dependencies..." composer install --optimize-autoloader --no-dev  echo "Installing and building frontend assets..." npm ci && npm run build  echo "Running migrations..." php artisan migrate --force  echo "Clearing and rebuilding caches..." php artisan config:cache php artisan route:cache php artisan view:cache php artisan event:cache  echo "Restarting queue workers..." php artisan queue:restart  echo "Restarting PHP-FPM..." sudo systemctl reload php8.2-fpm  echo "✅ Laravel + Livewire deployment complete!" 

Make it executable and run:

chmod +x deploy.sh ./deploy.sh 

Step 6: Post-Deployment Verification

After deploying, verify Livewire is working:

  1. Check the browser console — no JavaScript errors related to Livewire or Alpine
  2. Test a Livewire component — click buttons, submit forms, verify real-time updates work
  3. Check network tab — Livewire AJAX requests to /livewire/update should return 200
  4. Test file uploads — if your app uses Livewire file uploads, verify they work in production
  5. Monitor logstail -f storage/logs/laravel.log for any Livewire-related errors

Common Livewire Deployment Issues

"Livewire component not found" — Usually caused by stale route or view cache. Run php artisan route:clear && php artisan route:cache.

Alpine.js conflicts — If you see duplicate Alpine warnings, remove any standalone Alpine.js includes. Livewire v3 bundles it.

CSRF token mismatch — Ensure your session driver is configured correctly and sessions persist between requests. Redis sessions fix most issues.

Slow component updates — Enable Redis caching and ensure your server has adequate PHP-FPM workers configured.

Deploy Laravel + Livewire with DeployBase

A successful laravel + livewire deployment needs reliable infrastructure. At DeployBase, our VPS plans come with PHP 8.2+, Nginx, MySQL, and Redis pre-available — everything your Laravel + Livewire app needs. Starting at $5.99/month with NVMe SSD storage, full root access, and email support.

Get your VPS at DeployBase → — optimized hosting for Laravel applications.