Installation documentation
Ā
Version | Description | Date |
---|---|---|
1.0.1 | Initial document | 25 Dec 2023 |
1.0.2 | Update nginx config for static files | 11 Apr 2024 |
I. Server requirement
1. Web server
xStreamer supports almost OS: Windows, MacOS, Linux. However we recommend to use Linux, document is applied for linux system only.
For production environment, xStreamer needs a VPS server with at least:
4GB of RAM - recommend 8GB
40GB of HDD
2 CPU core
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
xStreamer architecture needs these softwares
NodeJS LTS version >= v20.x
To install please download NodeJS here
MongoDB >= v4.2
To install please download mongoDB
Redis server >= v6.1.x
To install please download and setup redis
Nginx >= v1.3 with http_auth_module is enabled
PM2 is a daemon process manager that will help you manage and keep your application online 24/7
Yarn to manage nodeJS package
Ensure all softwares above are running before setup source code
Helpful links
Testing
From command line / terminal please run these commands to check
1. NodeJS
$ node -v
v21.6.2
2. MongoDB
$ mongo --version
MongoDB shell version v4.2.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=6.1.4 sha=00000000:0 malloc=libc bits=64 build=d4ba11298acbb366
4. FFMPEG
5. NGINX
6. Pm2
7. Yarn
III. Setup and test project locally
We provide source code with 4 folders, check below and use in the app accordingly
front-office
web front-officeback-office
admin control panel for the applicationapi
api of the applicationconfig-sample
env
product environment example configapi.env
sample configuration for apifront-office.env
sample configuration for front webback-office.env
sample configuration for admin web
nginx
admin.example.com.conf
sample nginx configuration for admin webapi.example.com.conf
sample nginx configuration for apiexample.com.conf
sample nginx configuration for web front-office
1. API
Ensure
node v16.x
,MongoDB
,Redis server
,FFMPEG
andyarn
are runningCD to your API folder
Run
yarn insall --production=false
to install nodeJS dependencies and dev dependencies
Create new
.env
fromconfig-sample > env > api.env
file in the root dir
Ā
Content
.env
looks like below
Check Migration point to seed default
Run
yarn dev
to start development env
Ā
Open browsers and run
http://localhost:8080
it should show success message orHello World!
2. front-office web (front office)
Ensure
nodejs
andyarn
are runningFrom front-office root directory run
yarn insall --production=false
to install nodeJS dependencies and dev dependencies
Create
.env
file fromconfig-sample > env > front-office.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:8081
to see the web
3. Admin web
Similar front-office web, same steps.
Create
.env
file fromconfig-sample > env > back-office.env
. Content looks like below. Change it with your configuration accordingly
Run
yarn dev
to start development env
Then you can open browser
http://localhost:8082
to see the web
IV. Setup and setup production environment with nginx
1. API
Make sure you have installed nodeJS dependencies by
yarn install --production=false
command. Configure it like local setup,pm2
was installedIn API root directory, run
yarn build
Testing by run command
yarn start:prod
ornode dist/main.js
Run
pm2 start yarn --interpreter bash --name api.example.com -- start
to run application under port 8080
Note: If have error when starting with Pm2, please try to start without interpreter
2. front-office web
cd
front-office
folderMake sure you have installed nodeJS dependencies by
yarn install --production=false
command. Configure it like local setup,pm2
was installedRun
export NODE_ENV=production
Or editpackage.json
file > check build script from"build": "next build"
ā change to"build": "NODE_ENV=production next build"
Run
yarn build
Testing by run
yarn start
it should show success message
Run
pm2 start yarn --interpreter bash --name api.example.com -- start
to run application under port 8081. You can change port inpackage.json
in start script
Note: If have error when starting with Pm2, please try to start without interpreter
Ā
3. Admin web
cd
back-office
folderMake sure you have installed nodeJS dependencies by
yarn install --production=false
command. Configure it like local setup,pm2
was installedRun
export NODE_ENV=production
Or editpackage.json
file > check build script from"build": "next build"
ā change to"build": "NODE_ENV=production next build"
Run
yarn build
Testing by run
yarn start
it should show success messageRun
pm2 start yarn --interpreter bash --name admin.example.com -- start
to run application under port 8082. You can change port inpackage.json
in start script
Note: If have error when starting with Pm2, please try to start without interpreter
Ā
4. Setup nginx
a. Api
Let say our front-office code is in
/var/www/api.example.com
folder and api is running under port 8080, add new file in/etc/nginx/sites-enabled/api.example.com
and content as bellowYou have to change with our server name and source code path
b. Front office
Let say our front-office code is in
/var/www/example.com
folder and front-office app is running under port 8081, add new file in/etc/nginx/sites-enabled/example.com
and content as bellowYou have to change with our server name and source code path
c. Back office
Let say our back-office code is in
/var/www/admin.example.com
folder and back-office app is running under port 8082, add new file in/etc/nginx/sites-enabled/admin.example.com
and content as bellowYou have to change with our server name and source code path
d. Testing
Open browser and access: http://yourdomain.com to access web front-office
Open 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 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
Ā