Skip to main content

Guide to Install Web on VPS

This guide will help you install the Investra web frontend on VPS. This guide assumes you have already installed the admin panel on your VPS.

Watch on YouTube

Prerequisites

Before you start, make sure you have:

  • Admin panel already installed on your VPS
  • Node.js installed on your server (version 22 or higher)

Step 1: Upload the Web Files

  1. Create directories for client on /var/www/:
sudo mkdir /var/www/investra/client
  1. Give permission to the client directory:
sudo chown -R www-data:www-data /var/www/investra/client
sudo chmod -R 755 /var/www/investra/client
  1. Upload the standalone-client.zip file to the server:
scp -r core/standalone-client.zip root@server:/var/www/investra/client
  1. Extract the standalone-client.zip file:
cd /var/www/investra/client
unzip standalone-client.zip -d /var/www/investra/client
rm -rf standalone-client.zip

Step 2: Configure Nginx for Web

We'll create a new client configuration file:

sudo touch /etc/nginx/sites-available/investra-client.conf
sudo nano /etc/nginx/sites-available/investra-client.conf

Add this Nginx config:

server {
listen 80;
server_name YOUR_DOMAIN.com www.YOUR_DOMAIN.com;

root /var/www/investra/client;

location /_next/static/ {
alias /var/www/investra/client/.next/static/;
add_header Cache-Control "public, max-age=31536000, immutable";
}

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;
}
}

Make sure you change YOUR_DOMAIN.com to your specific domain name.

Then enable the config:

sudo ln -s /etc/nginx/sites-available/investra-client.conf /etc/nginx/sites-enabled/investra-client.conf

Step 3: Secure Server with SSL

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d YOUR_DOMAIN.com -d www.YOUR_DOMAIN.com

Step 4: Restart Nginx

Make sure you didn't introduce any syntax errors:

sudo nginx -t

Now, restart the Nginx service:

sudo systemctl restart nginx

Step 5: Web Part Installation

Go to the client directory:

cd /var/www/investra/client

Now run the following command:

Install dependencies:

npm install --force

Edit the .env file and update the values in the .env file.

cp .example.env .env

Now run the following command:

nano .env

Replace the values in the .env file:

NEXT_PUBLIC_API_URL=https://your-backend-url.com #required
NEXT_PUBLIC_TOKEN_NAME=token
NEXT_PUBLIC_ASSET_URL=https://your-backend-url.com

Build the project:

npm run build

Install PM2 globally:

npm install -g pm2

Start the project with PM2:

pm2 start npm --name "investra-client" -- run start
pm2 save

If you want to restart the project, use this command:

Restart the project:

pm2 restart investra-client

Note: It's important to run the project with PM2 to keep it running in the background.

Now you can access your Investra on your domain name.

Conclusion

Congratulations! You have successfully installed Investra web on your VPS. If you have any questions, please contact our support team.