DEV Community

Cover image for Deploying a Laravel E-Commerce App on Deploynix: From Cart to Production
Deploynix
Deploynix

Posted on • Originally published at deploynix.io

Deploying a Laravel E-Commerce App on Deploynix: From Cart to Production

E-commerce applications are among the most demanding Laravel projects to deploy correctly. They combine real-time inventory management, payment processing with strict webhook requirements, background job processing for emails and notifications, scheduled tasks for report generation and cart cleanup, and the absolute requirement that the checkout flow never goes down.

Getting a Laravel e-commerce app from your local development environment to a production server that handles real money involves more than just pushing code. The infrastructure decisions you make affect conversion rates, payment reliability, and customer trust.

This walkthrough takes you through the entire process: provisioning the server, configuring the database, setting up payment webhooks, deploying the application, configuring queue workers and scheduled jobs, securing everything with SSL, and going live.

We will use a typical Laravel e-commerce application as our reference — one that processes payments through Stripe or Paddle, sends transactional emails, manages inventory, and generates reports. The principles apply regardless of which e-commerce package or custom implementation you are using.

Planning Your Infrastructure

Before provisioning anything, decide on your infrastructure architecture. For a new e-commerce application, you have several options on Deploynix:

Single Server (Starting Out)

For applications with fewer than 10,000 daily visitors and moderate transaction volume, a single app server handles everything: web requests, queue processing, database, cache, and scheduled tasks. This is the simplest setup and the right starting point for most e-commerce projects.

Recommended specs: 2 vCPUs, 4GB RAM on DigitalOcean, Vultr, or Hetzner. This handles your web server (Nginx + PHP-FPM or Octane), MySQL or PostgreSQL, Valkey for cache and sessions, and queue workers comfortably.

Multi-Server (Scaling Up)

When your traffic or transaction volume outgrows a single server, Deploynix lets you split responsibilities:

  • Web server: Handles HTTP requests and serves your storefront.
  • Database server: Dedicated MySQL, MariaDB, or PostgreSQL instance.
  • Cache server: Dedicated Valkey instance for sessions, cache, and queue storage.
  • Worker server: Dedicated queue processing for order fulfillment, email sending, and report generation.

You can also add a Load Balancer in front of multiple web servers using Round Robin, Least Connections, or IP Hash methods.

For this walkthrough, we will start with a single app server — the most common starting point.

Step 1: Provision the Server

Log into your Deploynix dashboard and create a new server:

  1. Select your cloud provider (DigitalOcean, Vultr, Hetzner, Linode, AWS, or Custom).
  2. Choose the App Server type.
  3. Select your region — choose the region closest to your primary customer base.
  4. Select your server size (2 vCPUs, 4GB RAM is a solid starting point).
  5. Choose your database: MySQL is the most common for Laravel e-commerce, but PostgreSQL works equally well.
  6. Deploy the server.

Deploynix provisions the server, installs PHP, Nginx, your chosen database, Valkey, and configures the firewall with secure defaults. This takes about five minutes.

Step 2: Create Your Site

Once the server is provisioned:

  1. Navigate to the server in your Deploynix dashboard.
  2. Create a new site with your domain name (e.g., shop.example.com).
  3. Connect your Git repository from GitHub, GitLab, Bitbucket, or a custom Git provider.
  4. Select the branch to deploy (typically main or production).

Step 3: Configure Environment Variables

E-commerce applications have critical environment variables that must be configured before deployment. In the Deploynix site settings, set your environment variables:

APP_NAME="Your Shop Name"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://shop.example.com

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_shop
DB_USERNAME=your_user
DB_PASSWORD=your_secure_password

CACHE_STORE=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=your-smtp-host
MAIL_PORT=587
MAIL_USERNAME=your-smtp-user
MAIL_PASSWORD=your-smtp-password
MAIL_FROM_ADDRESS=orders@example.com
MAIL_FROM_NAME="Your Shop Name"
Enter fullscreen mode Exit fullscreen mode

Payment Provider Configuration

For Stripe:

STRIPE_KEY=pk_live_...
STRIPE_SECRET=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
Enter fullscreen mode Exit fullscreen mode

For Paddle:

PADDLE_VENDOR_ID=your_vendor_id
PADDLE_VENDOR_AUTH_CODE=your_auth_code
PADDLE_PUBLIC_KEY=your_public_key
PADDLE_WEBHOOK_SECRET=your_webhook_secret
Enter fullscreen mode Exit fullscreen mode

Never use test keys in production. Double-check that you are using live credentials, not sandbox ones. A surprisingly common launch-day mistake is deploying with test API keys.

Step 4: Configure Your Deploy Script

Set up your deploy script in Deploynix that handles the full Laravel e-commerce build process:

Install Dependencies:

composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
npm ci --no-audit --no-fund
Enter fullscreen mode Exit fullscreen mode

Build Frontend Assets:

npm run build
Enter fullscreen mode Exit fullscreen mode

Laravel Optimization:

php artisan migrate --force --no-interaction
php artisan storage:link
php artisan optimize
php artisan queue:restart
Enter fullscreen mode Exit fullscreen mode

The storage:link command is critical for e-commerce applications that serve product images from the storage directory. Without it, your product images will return 404 errors.

Step 5: Deploy the Application

Trigger your first deployment from the Deploynix dashboard or push to your connected branch. Deploynix executes a zero-downtime deployment:

  1. Creates a new release directory.
  2. Clones your repository.
  3. Runs your deploy script.
  4. Switches the live symlink to the new release.

If any step fails, the previous release (if one exists) continues serving traffic. Your first deployment does not have a previous release to fall back to, so verify your deploy script works correctly in a staging environment first.

After the deployment completes, verify the application is running by visiting your domain. You should see your storefront (or a setup page, depending on your application).

Step 6: SSL Certificate

Deploynix automatically provisions a Let's Encrypt SSL certificate for your site. After adding your domain and pointing DNS to your server, the certificate is issued within minutes.

For an e-commerce application, SSL is non-negotiable. Payment providers require HTTPS for webhook endpoints. Browsers display security warnings on HTTP pages with forms. Search engines penalize unencrypted sites.

Verify SSL is working by visiting https://shop.example.com and checking for the padlock icon. Deploynix handles certificate renewal automatically every 60 to 90 days.

Step 7: Configure Payment Webhooks

Payment webhooks are the most critical integration in an e-commerce application. When a customer completes a payment, Stripe or Paddle sends a webhook to your server confirming the transaction. If this webhook fails, orders are not fulfilled, inventory is not updated, and customers do not receive confirmation emails.

Stripe Webhooks

In your Stripe dashboard, configure your webhook endpoint:

  • URL: https://shop.example.com/stripe/webhook
  • Events: Select the events your application handles (typically checkout.session.completed, payment_intent.succeeded, payment_intent.payment_failed, customer.subscription.updated, etc.).

The webhook endpoint must be publicly accessible (not behind authentication middleware). In your Laravel routes, webhook routes should be defined outside any auth middleware group:

// routes/web.php
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handle']);
Enter fullscreen mode Exit fullscreen mode

Paddle Webhooks

For Paddle, configure the webhook URL in your Paddle dashboard:

  • URL: https://shop.example.com/paddle/webhook

Paddle sends webhooks for subscription events, payment completions, refunds, and more. Like Stripe, the endpoint must be publicly accessible.

Testing Webhooks

After deploying, test your webhook endpoints:

  • Stripe: Use the Stripe CLI to send test events: stripe trigger checkout.session.completed.
  • Paddle: Use Paddle's webhook simulator in the dashboard.

If webhooks fail, check your Deploynix server logs. Common issues include:

  • CSRF middleware blocking POST requests (exclude webhook routes from CSRF verification).
  • Incorrect webhook secrets causing signature validation failures.
  • Firewall rules blocking the payment provider's IP addresses (Deploynix's default firewall allows all HTTP/HTTPS traffic, so this is unlikely).

Step 8: Set Up Queue Workers

E-commerce applications rely heavily on queued jobs:

  • Sending order confirmation emails.
  • Processing payment notifications.
  • Updating inventory after purchases.
  • Generating invoices and receipts.
  • Syncing orders with external systems (accounting, shipping, CRM).
  • Sending abandoned cart reminders.

Configure queue workers in the Deploynix dashboard as daemons:

Primary worker (handles all queues):

  • Command: php artisan queue:work redis --queue=high,default,low --tries=3 --timeout=90
  • Processes: 2 (start with 2 and increase if your queue backs up)

Payment worker (dedicated to payment processing):

  • Command: php artisan queue:work redis --queue=payments --tries=5 --timeout=120
  • Processes: 1

Separating payment processing into a dedicated queue with higher retry counts ensures that payment-related jobs are not blocked by slower jobs like report generation or email sending.

Deploynix monitors your worker daemons and restarts them automatically if they crash. The queue:restart command in your deploy script ensures workers pick up new code after each deployment.

Step 9: Configure Scheduled Tasks

E-commerce applications need several scheduled tasks. Deploynix configures the Laravel scheduler automatically (* * * * * php artisan schedule:run), so you just need to define your tasks in routes/console.php:

Common e-commerce scheduled tasks:

// Clean up abandoned carts after 48 hours
Schedule::command('carts:cleanup --hours=48')->dailyAt('02:00');

// Generate daily sales reports
Schedule::command('reports:daily-sales')->dailyAt('06:00');

// Sync inventory with external systems
Schedule::command('inventory:sync')->everyFifteenMinutes();

// Process subscription renewals
Schedule::command('subscriptions:process-renewals')->hourly();

// Clear expired discount codes
Schedule::command('discounts:cleanup-expired')->daily();
Enter fullscreen mode Exit fullscreen mode

After deploying, verify your scheduled tasks are registered:

php artisan schedule:list
Enter fullscreen mode Exit fullscreen mode

Step 10: Database Backups

For an e-commerce application, database backups are not optional. A lost database means lost orders, lost customer data, and potential legal liability.

Configure automated backups in the Deploynix dashboard:

  1. Navigate to your server's backup settings.
  2. Select your database.
  3. Choose a backup storage destination: AWS S3, DigitalOcean Spaces, Wasabi, or custom S3-compatible storage.
  4. Set your backup schedule (daily is the minimum for e-commerce; every 6 hours is better).
  5. Configure backup retention (keep at least 30 days of backups).

Test your backup and restore process before going live. The worst time to discover your backups do not work is when you need to restore one.

Step 11: Pre-Launch Checklist

Before directing real customer traffic to your application, verify:

Security:

  • APP_DEBUG=false in production (exposing debug information leaks sensitive data).
  • APP_ENV=production.
  • SSL certificate is active and working.
  • Webhook endpoints are accessible and processing correctly.
  • Firewall is configured (Deploynix defaults are secure).
  • Payment provider is using live credentials, not test/sandbox.

Performance:

  • php artisan optimize has run (config, route, and event caching).
  • Frontend assets are compiled and minified (npm run build).
  • Database indexes exist for frequently queried columns (product slugs, order numbers, user IDs).
  • Queue workers are running and processing jobs.

Reliability:

  • Database backups are configured and tested.
  • Health monitoring is active on Deploynix.
  • Error tracking is configured (Sentry, Flare, or similar).
  • Scheduled tasks are registered and running.

Functionality:

  • Complete a test purchase with a real payment method.
  • Verify order confirmation emails are sent.
  • Verify webhook processing updates order status.
  • Verify inventory is updated after purchase.
  • Test the refund flow if applicable.

Going Live

With everything verified:

  1. Update your DNS records to point your domain to your Deploynix server's IP address.
  2. Wait for DNS propagation (typically 15 minutes to a few hours).
  3. Monitor your Deploynix dashboard for server health.
  4. Monitor your error tracking tool for application errors.
  5. Watch your queue processing to ensure jobs are completing.

The first few hours after launch are the most important. Keep your Deploynix dashboard and error tracking tool open. Watch for unexpected spikes in server resources, queue backlogs, or error rates.

Scaling When You Need It

Your single-server setup will carry you further than you might expect. A well-optimized Laravel e-commerce application on a 4GB server handles thousands of daily transactions without issue.

When you outgrow it, Deploynix makes scaling straightforward:

  • Add a database server to offload database processing.
  • Add a cache server for dedicated Valkey/Redis.
  • Add a worker server for queue processing.
  • Add web servers behind a load balancer for horizontal scaling.

Each scaling step is incremental. You do not need to re-architect your application — you just move components to dedicated servers as the load demands.

The Bottom Line

Deploying a Laravel e-commerce application is not complicated when you have the right platform. The critical elements — SSL, webhook reliability, queue processing, scheduled tasks, and database backups — are all first-class features in Deploynix, not afterthoughts you have to configure manually.

Your e-commerce application handles real money and real customer data. It deserves infrastructure that is as reliable as the code you have written. Deploynix provides that reliability without requiring you to become a systems administrator.

Top comments (0)