Installation Guide - xMember

I. Server Requirements:

xMember supports all platforms: Windows, MacOS, Linux.

xMember needs a VPS server with at least:

  • 2GB of RAM - recommend 4GB

  • 40GB of HDD

  • 1 CPU core - recommend 2 cores at least

  • 3 domains / sub domains

    • api.[your-domain] and point to server IP address

    • admin.[your-domain] and point to server IP address

    • [your-domain] and point to server IP address

II. Software Requirements:

Ensure all softwares above are running before setup source code

Testing

From command line / terminal please run these commands to check

1. NodeJS

$ node -v v16.16.2

2. MongoDB

$ mongo --version MongoDB shell version v4.0.7 git version: 1b82c812a9c0bbf6dc79d5400de9ea99e6ffa025 allocator: system modules: none build environment: distarch: x86_64 target_arch: x86_64

3. Redis server

$ redis-server --version Redis server v=5.0.4 sha=00000000:0 malloc=libc bits=64 build=d4ba11298acbb366

4. FFMPEG

5. NGINX

6. Pm2

7. Yarn

III. Setup and Test it Locally

We provide source code with 4 folders, check below and use in the app accordingly

  • user web frontend (front office)

  • admin backend (back office), admin control panel

  • api api of the app

  • config-example

    • env product environment example config

    • nginx nginx config example

1. API

  • Ensure node v12.x, MongoDB, Redis server, FFMPEG and yarn are running

  • CD to your API folder

  • Run yarn to install nodeJS dependencies. Make sure your NODE_ENV is not production or run yarn install --production=false to install both dependencies and devDependencies

  • Create new .env from config-example > env > api.env in the root dir

  • Content looks like below

  • Check Migration section to seed default data

  • Run yarn start:dev to start development env

  • Open browsers and run http://localhost:8080 it should show success message or Hello World!

2. User Frontend Web

  • Ensure nodejs and yarn are running

  • From user root directory run yarn to install nodeJS dependencies. Make sure your NODE_ENV is not production or run yarn install --production=false to install both dependencies and devDependencies

  • Create .env file from config-example > env > user.env and edit information accordingly. Content looks like below

  • Run yarn run dev to start development env

  • Then you can open browser http://localhost:8081 to see the web

3. Admin Web

  • Similar Frontend web, same steps.

  • CD to admin fodler

  • Create .env file from config-example > env > admin.env and edit information accordingly. Content looks like below

  • You should change default port with package.json file and change port number in start script "start": "next start -p 8082" then open http://localhost:8082 to see your admin app

IV. Setup Production Environment with NGINX

1. API

  • Make sure you have installed nodeJS dependencies by yarn command or run yarn install --production=false to install both dependencies and devDependencies

  • In API root directory, run yarn build

  • Testing by run command yarn start:prod or node dist/main.js

  • Run pm2 start dist/main.js --name=api to run API under background

Or run pm2 start yarn --interpreter bash --name xmember-api -- start:prod to run application under port 8080

Note: If have error when starting with Pm2, please try to start without interpreter

2. Frontend Web

  • Make sure you have installed nodeJS dependencies by yarn command or run yarn install --production=false to install both dependencies and devDependencies

  • Run yarn build

  • Testing by run yarn start it should show success message

  • Change port in package.json file at start script if needed "start": "next start -p 8081" with 8081 is port number

  • Run pm2 start yarn --name xmember -- start to run application

3. Admin Web

  • Similar Frontend web, same steps. Make sure all node dependencies are installed or run yarn install --production=false to install both dependencies and devDependencies

  • Run yarn build

  • Run export NODE_ENV=production

  • Change port in package.json file at start script if needed "start": "next start -p 8082" with 8082 is port number

  • Run pm2 start yarn --name xmember-admin -- start to run application

4. Setup NGINX

  • Api

    • Let say our api code is in /var/www/api.xmember.info folder and api is running under port 8080, add new file in /etc/nginx/sites-enabled/api.xmember.info and content as bellow

    • You have to change with our server name and source code path

  • Frontend

    • Let say our frontend code is in /var/www/xmember.info folder and Frontend app is running under port 8081, add new file in /etc/nginx/sites-enabled/xmember.info and content as bellow

    • You have to change with our server name and source code path

  • Admin

    • Let say our frontend code is in /var/www/admin.xmember.info folder and Frontend app is running under port 8082, add new file in /etc/nginx/sites-enabled/admin.xmember.info and content as bellow

    • You have to change with our server name and source code path

  • Testing

    • Open browser and access: https://yourdomain.com to access web frontend

    • Open browser and access: https://admin.yourdomain.com to access web admin

5. Check applications are running under pm2

  • Run pm2 ls to see your applications

  • Run pm2 stop [id] to stop app or pm2 reload [id] to reload

  • Run applications in start up by pm2 startup then pm2 save

6. Set up NGINX with HTTPS

7. Migration

  • From API root directory run yarn migrate to seed default values for settings and users

    • Default admin: admin@[yourdomain] with domain is in .env file

    • Default password: adminadmin

    • If admin password is wrong, you can run node script reset-admin-pw to reset it to adminadmin

  • You can change default values in src > migrations folder