Server Setups/Getting started
VPS Deployment & Management Guide
A consolidated guide to setting up a VPS with CloudPanel, securing it, and hosting your Next.js site.
On this page
Follow these steps to prepare your server and install the CloudPanel control panel.
1. Initial VPS & CloudPanel Setup
Connect & Update
Connect & Update
Step 01
SSH into your server as root
bash ssh root@your_new_server_ipStep 02
Update system packages
bash apt update && apt -y upgrade && apt -y install curl wget sudo
Install CloudPanel
Install CloudPanel
Step 01
Run the automated installer
bash curl -sS https://installer.cloudpanel.io/ce/v2/install.sh -o install.sh; \ sudo bash install.sh
Troubleshooting: Hostname Resolution
If the installer fails with "Hostname does not resolve":
echo "127.0.1.1 $(hostname -f) $(hostname)" >> /etc/hostsThen press the Up Arrow and hit Enter to re-run the installer.
2. Secure Code Deployment
Deploying your code securely from GitHub to your production environment.
Set Up Site User
Set Up Site User
Step 01
Switch to your site user
bash su - your_site_user
Generate Deployment Key
Generate Deployment Key
Step 01
Create the SSH key
bash ssh-keygen -t ed25519 -C "production-server"Step 02
Copy the public key to add to GitHub
Add this to Settings > Deploy Keys.
bash cat ~/.ssh/id_ed25519.pub
Clone the Repository
Clone the Repository
Step 01
Navigate to your site directory and clean the folder
bash cd ~/htdocs/brainnotfound.com rm -rf *Step 02
Clone the repository into the current directory
Note the
.at the end.bash git clone git@github.com:emmanuelonosode/branilizer.git .
3. Production Hosting (Next.js)
Preparing your application for 24/7 uptime.
Build and Launch
Build and Launch
Step 01
Build the production files
bash npm run buildStep 02
Install PM2 globally
bash npm install -g pm2Step 03
Start the application
bash pm2 start npm --name "brainnotfound" -- startStep 04
Save the process list
Auto-restart on reboot.
bash pm2 save
Configure Nginx Reverse Proxy
To make your Next.js app accessible via the domain, update the Vhost configuration in the CloudPanel dashboard:
Configure Nginx
Step 01
Go to the Vhost configuration
Navigate to Sites > brainnotfound.com > Vhost.
Step 02
Update the `location /` block
nginx location / { proxy_pass http://127.0.0.1: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; }Step 03
Click Save
Future Workflow (Updating Code)
Every time you push new changes from your Mac to GitHub, log in to your server and run these commands to update the site:
su - your_site_user
cd ~/htdocs/brainnotfound.com
git pull origin main
npm run build
pm2 restart brainnotfound