Skip to Content
Prodly 2.0 is released 🎉
InstallationSelf-hosted VPS Install

Self-hosted VPS Installation

This guide walks you through setting up Prodly on your own Virtual Private Server (VPS) for production use. By the end of these steps, you’ll have a fully functional instance running on your domain with HTTPS enabled.


Prerequisites

Before you begin, make sure you have the following:

  • A VPS with Ubuntu 20.04 or 22.04 (recommended)
  • Root access to your server via SSH
  • A domain name pointed to your server’s IP address
  • Node.js 18.x or later installed on your server
  • A Supabase account (free tier works) with a project already created
  • API keys for the services used by Prodly (see Environment Variables)

If you haven’t set up your environment variables yet, complete the Environment Setup guide first. You will need those values during installation.


Step‑by‑Step Installation

1. Connect to Your VPS

Open a terminal and connect to your server via SSH:

ssh root@your-server-ip

Replace your-server-ip with your actual server IP address.

2. Update the System

Update your package lists and upgrade existing packages:

apt update && apt upgrade -y

3. Install Node.js 18.x

Install Node.js 18.x from the official NodeSource repository:

curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt install -y nodejs

Verify the installation:

node --version npm --version

4. Install Git and Clone the Repository

Install Git:

apt install -y git

Clone the Prodly repository (you’ll need access to the private repository):

git clone https://github.com/your-organization/prodly.git cd prodly

Replace the URL with the actual repository URL you were provided.

5. Install Dependencies

Install all required packages:

npm install

This will read the package.json and install everything needed to run the application.

6. Set Up Environment Variables

Create a .env.production file in the project root:

nano .env.production

Add all the required variables. Make sure to use your Supabase project credentials – do not set up a local PostgreSQL database.

# Domain (use your actual domain) NEXT_PUBLIC_APP_URL=https://yourdomain.com # Supabase (required – Prodly uses Supabase for auth and database) NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key # AI - Text generation (Groq) GROQ_API_KEY=your_groq_api_key # AI - Image analysis (Google Gemini) GOOGLE_API_KEY=your_google_gemini_api_key # Keyword suggestions (Serper) SERPER_API_KEY=your_serper_api_key # Rate limiting (Upstash Redis) UPSTASH_REDIS_REST_URL=your_upstash_redis_url UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_token # Stripe (if you use payments) STRIPE_SECRET_KEY=sk_live_... NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_... STRIPE_WEBHOOK_SECRET=whsec_...

Save the file and exit (Ctrl+X, then Y, then Enter).

Never commit .env.production to version control. Keep it secure on your server.

7. Set Up the Database Schema in Supabase

Prodly uses Supabase as its database. You need to apply the database schema to your Supabase project. Do not install PostgreSQL on your VPS – the database is managed by Supabase.

  1. Log in to your Supabase Dashboard .

  2. Open your project.

  3. Go to the SQL Editor.

  4. Copy the entire contents of supabase-schema.sql (provided in the project root) and paste it into a new query.

Run the query. This will create all the required tables and set up Row Level Security policies, including the automatic admin trigger for the first user.

If you prefer to run migrations manually, you can also use the Supabase CLI, but the SQL editor is the simplest approach.

8. Build the Application

Build the Next.js application for production:

npm run build

This will create an optimized production build in the .next folder.

9. Install PM2 Process Manager

PM2 will keep your application running and restart it automatically if it crashes:

npm install -g pm2

Start the application with PM2:

pm2 start npm --name "prodly" -- start

Configure PM2 to start on system boot:

pm2 startup systemd pm2 save

10. Set Up Nginx as a Reverse Proxy

Install Nginx:

apt install -y nginx

Create a new Nginx configuration file:

nano /etc/nginx/sites-available/prodly

Add the following configuration (replace yourdomain.com with your actual domain):

server { listen 80; server_name yourdomain.com www.yourdomain.com; location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

Enable the site:

ln -s /etc/nginx/sites-available/prodly /etc/nginx/sites-enabled/ nginx -t systemctl reload nginx

11. Set Up SSL with Let’s Encrypt

Install Certbot:

apt install -y certbot python3-certbot-nginx

Obtain an SSL certificate:

certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts to complete the setup. Certbot will automatically update your Nginx configuration to use HTTPS.

12. Configure Firewall (if enabled)

If you’re using UFW, allow necessary ports:

ufw allow 22 ufw allow 80 ufw allow 443 ufw enable

13. First User Becomes Admin Automatically

The database schema you applied in Supabase includes a special mechanism that grants administrator privileges to the very first user who registers. Here’s how it works:

  • A trigger on the user_profiles table runs before a new row is inserted.

  • It calls a function handle_first_user_admin() that checks if any user profile already exists in the table.

  • If no profiles exist (i.e., this is the first user), the function sets is_admin = TRUE for the new profile.

  • All subsequent users will have is_admin = FALSE by default.

What this means for you:

  1. After completing the installation, register immediately – the account you create will become the administrator.

  2. You can then access the admin panel at https://yourdomain.com/admin  with full privileges.

  3. No manual SQL updates are required for the first user.

If you already have users in your database before adding the trigger (for example, if you ran the schema without the trigger or created users earlier), the automatic mechanism won’t apply. In that case, you can manually promote a user to admin using the following SQL in the Supabase SQL Editor (replace user@example.com with the actual email):

UPDATE user_profiles SET is_admin = true WHERE id = (SELECT id FROM auth.users WHERE email = 'user@example.com');

14. Verify Everything Works

  • Visit https://yourdomain.com  in your browser.

  • Register a new user account (this will be your admin account).

  • Check that you can access the admin panel at https://yourdomain.com/admin .

  • Test description generation (trial generation).

  • Verify that credits are deducted correctly.

  • If you’ve set up Stripe, test a payment using Stripe test cards.

🆘 Troubleshooting VPS Installation

ProblemSolution
npm install failsMake sure you have Node.js 18+ installed. Delete node_modules and package-lock.json, then run npm install again.
Database connection errorDouble-check your Supabase URL and keys in .env.production. Ensure your Supabase project is active and the credentials are correct.
Missing environment variable errorVerify that all required variables are set in .env.production. Refer to the Environment Setup guide for a complete list.
Port 3000 already in useEither stop the process using that port or change the port in the PM2 start command.
Nginx configuration errorRun nginx -t to check for syntax errors. Make sure the configuration file is linked correctly in sites-enabled.
SSL certificate issueEnsure your domain points to your server’s IP before running Certbot. Check that ports 80 and 443 are open in your firewall.
License key invalidEnsure the LICENSE_KEY in your .env.production matches the one you received. Contact support if the issue persists.
Application not starting with PM2Check the logs with pm2 logs prodly. Make sure all environment variables are correctly set.

🔧 Maintenance Commands

CommandDescription
pm2 statusCheck if the application is running
pm2 logs prodlyView application logs
pm2 restart prodlyRestart the application
pm2 stop prodlyStop the application
pm2 delete prodlyRemove the application from PM2
systemctl reload nginxReload Nginx configuration
certbot renew —dry-runTest SSL certificate renewal

Next Steps

Once your VPS installation is running smoothly, you can:

  • Set up Stripe for payments (see Stripe Setup) .

  • Set up regular database backups via Supabase (Supabase provides point-in-time recovery on paid plans).

  • Monitor server performance and logs.

Happy hosting!

Last updated on