Installation Documentation - xChat
- 1 I. Server Requirements
- 2 II. Software Requirements
- 2.1 Testing
- 2.1.1 1. NodeJS
- 2.1.2 2. MongoDB
- 2.1.3 3. Redis Server
- 2.1.4 4. FFMPEG
- 2.1.5 5. NGINX
- 2.1.6 6. Graphicsmagick
- 2.1.7 7. Pm2
- 2.1.8 8. Yarn
- 2.1 Testing
- 3 III. Setup and Test It Locally
- 3.1.1 1. API
- 3.1.2 2. Frontend Web
- 3.1.3 3. Admin Web
- 3.2 IV. Setup Production Environment with NGINX
- 3.2.1 1. API
- 3.2.2 2. Frontend Web
- 3.2.3 3. Admin Web
- 3.2.4 4. Setup NGINX
- 3.2.5 5. Check applications are running under pm2
- 3.2.6 6. Set up NGINX with HTTPS
- 3.2.7 7. Migration
I. Server Requirements
xChat supports all platforms: Windows, MacOS, Linux.
xChat 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 addressadmin.[your-domain]
and point to server IP address[your-domain]
and point to server IP address
II. Software Requirements
MongoDB
v4.0
- To install please download mongoDBRedis server
v2.8
- To install please download and setup RedisNginx
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
Typescript 4.2.3 or higher - To install run
npm install typscript@latest
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
v14.16.0
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. Graphicsmagick
7. Pm2
8. Yarn
III. Setup and Test It Locally
1. API
Ensure
node v14.x
,MongoDB
,Redis server
,FFMPEG
,Graphicsmagick
andyarn
are runningCD to your API folder
Run
yarn
to install nodeJS dependencies
Create new
.env
from.env.example
file in the root dir
Open file
.env
and change config
Run
yarn dev
to start development env
Open browsers and run
http://localhost:9000
it should show success message orCannot GET /
2. Frontend Web
Ensure
nodejs
andyarn
are runningFrom frontend root directory run
yarn
command to install nodejs dependencies
Open
config > shared.ts
file and edit information. Change with your url indevelopment
orproduction
API url
Run
export PORT=8081
or edit default port inserver/index.ts
at line 7const port = parseInt(process.env.PORT || '8081', 10)
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.
You should change default port with
8082
then openhttp://localhost:8082
to see your admin app
IV. Setup Production Environment with NGINX
1. API
Make sure you have installed nodeJS dependencies by
yarn
commandIn API root directory, copy
config > development.json
toconfig > production.json
Open
.env
file and changeNODE_ENV
toproduction
PORT
to 8080Change your base url, logoUrl… to your production Url
Replace your real logo in public > assets folder.
Change related info such as MongoDB, redis uri for production env
Testing by run command
yarn start
ornode server/www.js
Run
pm2 start server/www.js --name=api
to run API under background
2. Frontend Web
Make sure you have installed nodeJS dependencies by
yarn
commandEdit your API url and socket Url in
config > shared.ts
Run
yarn build
Run
export PORT=8081
or change port inserver > index.ts
fileTesting by run
yarn start
ornode dist/index.js
it should show success message
Run
pm2 start yarn --interpreter bash --name xchat-web
to run application under port 8081
3. Admin Web
Similar Frontend web, same steps.
You should change default port to 8082 by
export PORT=8082
or change port inserver > index.ts
fileRun
pm2 start yarn --interpreter bash --name xchat-admin
to run app under port 8082
4. Setup NGINX
Config ports api, web, admin as following
API
: 8080Web
: 8081Admin
: 8082
Api
Let say our api code is in
/var/www/api.xchat.info
folder and api is running under port 8080, add new file in/etc/nginx/sites-enabled/api.xchat.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/xchat.info
folder and Frontend app is running under port 8081, add new file in/etc/nginx/sites-enabled/xchat.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.xchat.info
folder and Frontend app is running under port 8082, add new file in/etc/nginx/sites-enabled/admin.xchat.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
node server/migrate
to seed default values for settings and usersDefault Admin:
admin@example.com
Default Password:
admin
You can change default values in server > migrations folder