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-ipReplace 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 -y3. 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 nodejsVerify the installation:
node --version
npm --version4. Install Git and Clone the Repository
Install Git:
apt install -y gitClone the Prodly repository (youâll need access to the private repository):
git clone https://github.com/your-organization/prodly.git
cd prodlyReplace the URL with the actual repository URL you were provided.
5. Install Dependencies
Install all required packages:
npm installThis 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.productionAdd 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).
.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.
-
Log in to your Supabase Dashboard .
-
Open your project.
-
Go to the SQL Editor.
-
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.
8. Build the Application
Build the Next.js application for production:
npm run buildThis 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 pm2Start the application with PM2:
pm2 start npm --name "prodly" -- startConfigure PM2 to start on system boot:
pm2 startup systemd
pm2 save10. Set Up Nginx as a Reverse Proxy
Install Nginx:
apt install -y nginxCreate a new Nginx configuration file:
nano /etc/nginx/sites-available/prodlyAdd 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 nginx11. Set Up SSL with Letâs Encrypt
Install Certbot:
apt install -y certbot python3-certbot-nginxObtain an SSL certificate:
certbot --nginx -d yourdomain.com -d www.yourdomain.comFollow 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 enable13. 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_profilestable 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 = TRUEfor the new profile. -
All subsequent users will have
is_admin = FALSEby default.
What this means for you:
-
After completing the installation, register immediately â the account you create will become the administrator.
-
You can then access the admin panel at https://yourdomain.com/admin with full privileges.
-
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
| Problem | Solution |
|---|---|
| npm install fails | Make sure you have Node.js 18+ installed. Delete node_modules and package-lock.json, then run npm install again. |
| Database connection error | Double-check your Supabase URL and keys in .env.production. Ensure your Supabase project is active and the credentials are correct. |
| Missing environment variable error | Verify that all required variables are set in .env.production. Refer to the Environment Setup guide for a complete list. |
| Port 3000 already in use | Either stop the process using that port or change the port in the PM2 start command. |
| Nginx configuration error | Run nginx -t to check for syntax errors. Make sure the configuration file is linked correctly in sites-enabled. |
| SSL certificate issue | Ensure your domain points to your serverâs IP before running Certbot. Check that ports 80 and 443 are open in your firewall. |
| License key invalid | Ensure the LICENSE_KEY in your .env.production matches the one you received. Contact support if the issue persists. |
| Application not starting with PM2 | Check the logs with pm2 logs prodly. Make sure all environment variables are correctly set. |
đ§ Maintenance Commands
| Command | Description |
|---|---|
| pm2 status | Check if the application is running |
| pm2 logs prodly | View application logs |
| pm2 restart prodly | Restart the application |
| pm2 stop prodly | Stop the application |
| pm2 delete prodly | Remove the application from PM2 |
| systemctl reload nginx | Reload Nginx configuration |
| certbot renew âdry-run | Test 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!