Installation Documentation - xModel
- 1.1 I. Server Requirements
- 1.1.1 1. Web Server
- 1.1.2 2. Streaming Server
- 1.2 II. Software Requirements
- 1.2.1 Testing
- 1.2.1.1 1. NodeJS
- 1.2.1.2 2. MongoDB
- 1.2.1.3 3. Redis Server
- 1.2.1.4 4. FFMPEG
- 1.2.1.5 5. NGINX
- 1.2.1.6 6. Pm2
- 1.2.1.7 7. Yarn
- 1.2.1 Testing
- 1.3 III. Setup and Test it Locally
- 1.3.1 1. API
- 1.3.2 2. Frontend Web
- 1.3.3 3. Admin Web
- 1.1 I. Server Requirements
- 2 IV. Setup Production Environment with NGINX
I. Server Requirements
1. Web Server
xModels supports all platforms: Windows, MacOS, Linux.
xModels needs a VPS server with at least:
4GB of RAM - recommend 8GB
40GB of HDD
1 CPU core - recommend 2 cores at least
4 domains / sub domains
api.[your-domain]
and point to server IP addressadmin.[your-domain]
and point to server IP addressstreaming.[your-domain]
and point to server IP address[your-domain]
and point to server IP address
2. Streaming Server
xModel use Ant media as a media streaming service for broadcast, private and group chat. Recommend server with at least
Ubuntu 20.x
4GB of RAM
2 CPU core - CPU optimized
Streaming domain like streaming [your-domain]
Note: Ant media is able to be installed on Ubuntu 18.04
, Ubuntu 20.04
or CentOS 8
only
II. Software Requirements
xModels architecture needs these softwares
NodeJS
v16.x
To install please download NodeJS here
MongoDB
v3.6
To install please download mongoDB
Redis server
v2.8
To install please download and setup redis
Nginx
v1.3
PM2 is a daemon process manager that will help you manage and keep your application online 24/7
Yarn or npm to manage nodeJS package
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
v12.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 panelapi
api of the appconfig-example
env
product environment example confignginx
nginx config example
1. API
Ensure
node v16.x
,MongoDB
,Redis server
,FFMPEG
andyarn
are runningCD to your API folder
Run
yarn
to install nodeJS dependencies
Create new
.env
fromconfig-example > env > api.env
file in the root dir
Content
.env
looks like below
Check Migration point to seed default
Run
yarn start:dev
to start development env
Open browsers and run
http://localhost:8080
it should show success message orHello World!
2. Frontend Web
Ensure
nodejs
andyarn
are runningFrom frontend root directory run
yarn
command to install nodejs dependencies
Create
.env
file fromconfig-example > env > user.env
. Content looks like below. Change it with your configuration accordingly
Then you can open browser
http://localhost:8081
to see the web
3. Admin Web
Similar Frontend web, same steps.
Create
.env
file fromconfig-example > env > user.env
. Content looks like below. Change it with your configuration accordingly
Run
yarn run dev
to start development env
Then you can open browser
http://localhost:8082
to see the web
IV. Setup Production Environment with NGINX
1. API
Make sure you have installed nodeJS dependencies by
yarn
commandIn API root directory, run
yarn build
Testing by run command
yarn start:prod
ornode dist/main.js
Run
pm2 start dist/main.js --name=api
to run API under background
Or run pm2 start yarn --interpreter bash --name xmodels-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
commandRun
yarn build
Run
pm2 start dist/index.js --name xmodels-web -- start
to run application
3. Admin Web
Similar Frontend web, same steps.
Run
yarn build
Run
pm2 start dist/index.js --name xmodels-admin -- start
to run application
4. Setup NGINX
Api
Let say our frontend code is in
/var/www/api.xmodels.info
folder and api is running under port 8080, add new file in/etc/nginx/sites-enabled/api.xmodels.info
and content as bellowYou have to change with our server name and source code path
Frontend
Let say our frontend code is in
/var/www/xmodels.info
folder and Frontend app is running under port 8081, add new file in/etc/nginx/sites-enabled/xmodels.info
and content as bellowYou have to change with our server name and source code path
Admin
Let say our frontend code is in
/var/www/admin.xmodels.info
folder and Frontend app is running under port 8082, add new file in/etc/nginx/sites-enabled/admin.xmodels.info
and content as bellowYou have to change with our server name and source code path
Testing
Open browser and access:
http://yourdomain.com
to access web frontendOpen browser and access:
http://admin.yourdomain.com
to access web admin
5. Check applications are running under pm2
Run
pm2 ls
to see your applicationsRun
pm2 stop [id]
to stop app orpm2 reload [id]
to reloadRun applications in start up by
pm2 startup
thenpm2 save
6. Set up NGINX with https
Check here to setup https with nginx
Setup https with Certbot nginx
7. Migration
From API root directory run
yarn migrate
to seed default values for settings and usersDefault admin:
admin@[yourdomain]
with domain is in .env fileDefault 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