Introduction
- Thank you for choosing the Funbun app. We are pleased to have you with us. Enclosed is the documentation to help you set up and launch the app easily. Please read it carefully, as it contains important information. If you need any assistance or have questions, our support team is just a message away.
Extract Project Zip
- All setup is performed using Terminal (SSH).
- Connect to your AWS server using:
ssh ubuntu@YOUR_SERVER_IP
- Upload the backend zip file using WinSCP or SCP.
- Navigate to your project directory and extract:
cd /home/ubuntu/funbun
unzip backend.zip -d backend
Create Instance In AWS
- Launch an AWS EC2 Instance.
- Instance Type: t3a.medium
- Operating System: Ubuntu 24.04 LTS
- Enable ports in Security Group:
- 22 – SSH
- 80 – HTTP
- 443 – HTTPS
- Attach key pair and launch the instance.
Setup MariaDB (MySQL)
- Update system packages:
sudo apt update && sudo apt upgrade -y
- Install MariaDB (MySQL compatible):
sudo apt install mariadb-server -y
- Verify version:
mysql --version
mysql Ver 15.1 Distrib 10.6.22-MariaDB
- Secure the database:
sudo mysql_secure_installation
Setup Nginx
- Install Nginx:
sudo apt install nginx -y
- Check Nginx version:
nginx -v
nginx/1.18.0 (Ubuntu)
- Start and enable Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
Setup Node.js And PM2
- Install NVM (Node Version Manager):
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh |
bash
- Reload terminal:
source ~/.bashrc
- Install Node.js version v20.19.4:
nvm install 20.19.4
nvm use 20.19.4
nvm alias default 20.19.4
- Verify Node and npm:
node -v
v20.19.4
npm -v
10.8.2
- Install PM2 globally:
npm install -g pm2
Setup Database In MariaDB
- Login to MariaDB:
sudo mysql
- Create database and user:
CREATE DATABASE funbun;
CREATE USER 'funbun_user'@'localhost' IDENTIFIED BY
'StrongPassword@123';
GRANT ALL PRIVILEGES ON funbun.* TO
'funbun_user'@'localhost';
FLUSH PRIVILEGES;
- copy schema.sql file from database folder into /home/ubuntu folder in server
- Import the database schema:
mysql -u funbun_user -p funbun < /home/ubuntu/schema.sql
Setup Project In Server
- Navigate to project directory:
cd /home/ubuntu/funbun/backend
- Setup and configure the .env file:
mv .env.example .env
- Edit the .env file and update database, server, and app settings.
- Install project dependencies:
npm install
- Notification Setup (Firebase)
- Go to Firebase Console → Project Settings → Service Accounts.
- Click Generate new private key and download the JSON file.
- Upload the downloaded file to the backend config folder:
/home/ubuntu/funbun/backend/config
- Rename the downloaded file to firebase.json:
mv firebase-adminsdk-xxxxx.json firebase.json
- Start backend using PM2:
pm2 start index.js --name funbun
pm2 save
pm2 startup
- Restart backend after Firebase setup:
pm2 restart funbun
Configure Nginx Reverse Proxy (Without SSL)
- All steps are performed using Terminal (SSH).
- Create a new Nginx configuration file for your domain:
sudo nano /etc/nginx/sites-available/funbundev.yourdworld.com
- Paste the following configuration (WITHOUT SSL):
server {
listen 80;
server_name funbundev.yourdworld.com;
access_log /var/log/nginx/funbundev.access.log;
error_log /var/log/nginx/funbundev.error.log;
# Main application proxy
location / {
proxy_pass http://127.0.0.1:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
# Socket.IO proxy
location /socket.io/ {
proxy_pass http://127.0.0.1:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
- Enable the site:
sudo ln -s /etc/nginx/sites-available/funbundev.yourdworld.com
/etc/nginx/sites-enabled/
- Test Nginx configuration:
sudo nginx -t
- Restart Nginx:
sudo systemctl restart nginx
- Verify your application is accessible at:
http://funbundev.yourdworld.com
SSL Certificate Setup (Let’s Encrypt + Certbot)
Step 1: Install Certbot
- Update package list:
sudo apt update
- Install Certbot with Nginx plugin:
sudo apt install certbot python3-certbot-nginx -y
Step 2: Generate SSL Certificate (Let’s Encrypt)
- Run the following command to generate SSL for your domain:
sudo certbot --nginx -d funbundev.yourdworld.com
- During the process:
- Enter your email address for renewal notifications
- Agree to the Let’s Encrypt terms
- Select the option to redirect HTTP to HTTPS
Step 3: Locate Generated Certificate Files
- After successful installation, Let’s Encrypt generates certificate files at:
/etc/letsencrypt/live/funbundev.yourdworld.com/
- Main files:
-
fullchain.pem – SSL Certificate
(contains
-----BEGIN CERTIFICATE-----) -
privkey.pem – Private Key
(contains
-----BEGIN PRIVATE KEY-----)
Step 4: Use Certificate in Your Backend (If Required)
- If your Node.js backend requires manual certificate files:
- Open your backend config directory.
-
Copy content of:
-
/etc/letsencrypt/live/funbundev.yourdworld.com/fullchain.pem→ paste into production.funbun.crt
-
/etc/letsencrypt/live/funbundev.yourdworld.com/privkey.pem→ paste into production.funbun.key
-
- Restart your Node.js server after updating files.
Step 5: Verify Auto-Renewal
- Test automatic renewal:
sudo certbot renew --dry-run
Final Access URL
https://funbundev.yourdworld.com
Admin Panel Setup
- Open Admin Code in Vs studio code
- Rename .env.example to .env
- Edit env file in admin
- update backend url to https://funbundev.yourdworld.com
- install Node modules
npm i
- Create production build:
npm run build
- Upload build files into backend admin directory.
- Access admin panel via configured domain.
Env file explain
- PORT: The port number where your Node.js project runs. Commonly, 3000 or 5000.
- TOKEN_KEY: A secret key used for JWT encryption and authentication for API requests.
- DATABASE_HOST: The SQL database hostname. Usually set to "localhost" for local development.
- DATABASE_NAME: The name of your SQL database.
- DATABASE_USERNAME: The username used to connect to your database.
- DATABASE_PASSWORD: The password associated with your database username.
- DATABASE_PORT: The database port number. For MySQL/MariaDB, the default is 3306.
- APP_URL: The base URL of your backend server that your frontend or mobile app will call.
- SERVER: Environment mode. Use development for local testing or production for a live server.
- REVENUE_CAT_PLAY_STORE_V1_API_KEY: RevenueCat API Key for handling Google Play Store subscriptions.
- REVENUE_CAT_APP_STORE_V1_API_KEY: RevenueCat API Key for handling Apple App Store subscriptions.
- FIREBASE_WEB_APP_KEY: Firebase Web API Key, used for dynamic links or Firebase Web SDK integrations.
- CURRENCY_API: Your currency API key (e.g., from CurrencyAPI) used for fetching exchange rates.
SetUp Agora
- How to setup project at agora and getting credentials
- Sign up at theAgora Console.
- Navigate to the sidebar and click on "Project Management."
- Select "Create New Project."
- Fill in all the required information.
- Click on "Submit" to finalize the creation of your new project.
- Once your project is created, copy the Agora App ID for future use.
- Click on the "Configure" button. This will display the configuration page as shown below.
- On the configuration page, copy the Agora App Certificate for future use.
- This process allows you to obtain the App ID and App Certificate for your Agora project from the console.
- Enter the Agora Key and Agora Certificate In details in the admin panel under the plugin section In VideoCall plugin.
RevenueCat Configuration
- Navigate to https://www.revenuecat.com/.
- Log in using your RevenueCat credentials.
- Next, you need to add the App Store Key and Play Store Key to code. You can get these keys by going to the RevenueCat dashboard > API Keys > Secret Api Keys. Copy and paste these keys into the respective fields of code.
- Copied key paste to config > .env. in backend env key name is REVENUE_CAT_APP_STORE_V1_API_KEY and REVENUE_CAT_PLAY_STORE_V1_API_KEY
SMTP Configuration
- The first step of the process is to create an email account on your hosting package.
- Once you have your email account created, you can proceed with the actual configuration of your Funbun website. You need to access your website as administrator and go to SMTP settings from Admin Panel -> Plugin -> SMTP config
-
Edit the following options:
- SMTP Host -mail.example.com (change example.com to your actual domain)
- SMTP Username - Enter the email account created in the previous chapter
- SMTP Password - Enter the password for your email account
- SMTP Port - server port, most used 587 for TLS, and 465 for SSL encryption
- I made the changes above but my website is not sending any emails, what I can do?
- Please test your SMTP credentials at SMTPER, if the same config worked by the test, please contact us.
Dynamic Link
- Begin by visiting the Firebase website through the following link: https://firebase.google.com/
- If you do not already have a Firebase account, kindly sign up for one. Otherwise, proceed to sign in with your existing account credentials.
- Navigate to the "Project Overview" section and click the setting icon.