Skip to content

How to Deploy a Shopify Remix + Laravel App on DigitalOcean (Step-by-Step Guide)

Deploying a full-stack application that integrates Shopify, Remix, and Laravel requires a well-structured approach. In this guide, we’ll walk through setting up a DigitalOcean droplet, installing necessary dependencies, configuring servers, and deploying both the Laravel backend and the Remix frontend for your Shopify app.


Prerequisites

Before getting started, ensure you have:

  • ✅ A DigitalOcean account
  • ✅ A registered domain (recommended)
  • ✅ Basic knowledge of Linux commands
  • SSH access to your DigitalOcean droplet

Step 1: Set Up the DigitalOcean Droplet

Connect to Your Droplet via SSH

ssh root@your-droplet-ip

Update System & Install Required Packages

apt update && apt upgrade -y
apt install -y nginx git curl unzip ufw

Step 2: Install Node.js, PHP, and MySQL

Install Node.js and PNPM

curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
source ~/.bashrc
nvm install 22.14.0
nvm use 22.14.0
npm install -g pnpm pm2

Install PHP 8.3 and Dependencies

add-apt-repository ppa:ondrej/php -y
apt update
apt install -y php8.3 php8.3-cli php8.3-fpm php8.3-mbstring php8.3-xml php8.3-bcmath php8.3-curl php8.3-mysql unzip zip

Install MySQL and Secure It

apt install -y mysql-server
mysql_secure_installation

Create Database and User

CREATE DATABASE your_database;
CREATE USER 'database_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'database_user'@'localhost';
FLUSH PRIVILEGES;

Restart MySQL

sudo systemctl restart mysql

Step 3: Install and Configure Redis

apt install -y redis-server
vim /etc/redis/redis.conf

Modify these settings:

requirepass your_secure_redis_password
bind 127.0.0.1
supervised systemd

Restart Redis:

systemctl restart redis

Step 4: Set Up Git and Clone Repositories

Generate SSH Key and Add to GitHub

ssh-keygen -t rsa -b 4096 -C '[email protected]'
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub

Test Connection:

ssh -T [email protected]

Clone Laravel Backend:

cd /var/www
git clone [email protected]:YourUsername/yourLaravelRepo.git
cd yourLaravelRepo

Step 5: Configure Laravel

cp .env.example .env
vim .env

Install Dependencies & Optimize

composer install --no-dev --optimize-autoloader
php artisan storage:link
php artisan key:generate
php artisan config:cache
php artisan route:cache

Set Permissions

chown -R www-data:www-data /var/www/yourLaravelRepo
chmod -R 775 /var/www/yourLaravelRepo/storage /var/www/yourLaravelRepo/bootstrap/cache

Step 6: Set Up Supervisor for Laravel Queues

Install & Configure Supervisor

apt install -y supervisor
vim /etc/supervisor/conf.d/laravel-worker.conf

Add:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/yourLaravelRepo/artisan queue:work redis --tries=3
autostart=true
autorestart=true
numprocs=1
user=www-data
redirect_stderr=true
stdout_logfile=/var/log/worker.log

Start Supervisor:

supervisorctl reread
supervisorctl update
supervisorctl start laravel-worker:*

Step 7: Deploy Remix Frontend

Clone Remix App:

cd /var/www
git clone [email protected]:YourUsername/yourRemixRepo.git
cd yourRemixRepo

Set Environment Variables

cp .env.example .env
vim .env

Example:

NODE_ENV=production
SHOPIFY_APP_URL=https://your-shopify-app-url.com
DATABASE_URL="mysql://database_user:your_secure_password@localhost:3306/database"

Install Dependencies & Build

pnpm install
pnpm run build

Start with PM2

pm2 start npm --name yourRemixRepo -- start
pm2 save
pm2 startup

Step 8: Configure Nginx for Laravel and Remix

Laravel Nginx Configuration

vim /etc/nginx/sites-available/yourLaravelRepo

Add:

server {
    listen 80;
    server_name api.yourdomain.com;
    root /var/www/yourLaravelRepo/public;
    index index.php index.html;
    location / { try_files $uri $uri/ /index.php?$query_string; }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Remix Nginx Configuration

vim /etc/nginx/sites-available/yourRemixRepo
server {
    listen 443 ssl;
    server_name app.yourdomain.com;
    ssl_certificate /etc/letsencrypt/live/app.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.yourdomain.com/privkey.pem;
    root /var/www/yourRemixRepo/build;
    index index.html;
    location / { proxy_pass http://localhost:3000; }
}

Enable & Restart Nginx:

ln -s /etc/nginx/sites-available/yourLaravelRepo /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/yourRemixRepo /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx

Step 9: Secure with SSL

apt install -y certbot python3-certbot-nginx
certbot --nginx -d app.yourdomain.com -d api.yourdomain.com

Auto-Renew SSL:

echo "0 0 * * * certbot renew --quiet" | crontab -

Conclusion

Your Shopify Remix + Laravel app is now successfully deployed on DigitalOcean, secured with SSL, and optimized for performance. 🚀 If you need assistance, feel free to reach out!


🔥 Have Questions?

Let us know in the comments below!

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − 7 =