xChat - Installation Document

Adult sexting app - v1
adentio9
Site Admin
Posts: 114
Joined: Tue Aug 11, 2015 7:12 am

xChat - Installation Document

Postby adentio9 » Fri Jul 10, 2020 8:21 am

Step 1 - Getting started
- OS: Recommend Linux system
- Guide for ubuntu system
- Need 3 domains and https for all. You should register wild card for SSL. Go to your DNS manager and point 3 domains above to your server
Web user: https://yourapp.com
Admin: https://admin.yourapp.com
API: https://api.yourapp.com

Step 2 - Softwares

1. NodeJS

- Version >= 8.1
- More information you can check https://nodejs.org/en/download/package-manager/Here
- Install
Open your terminal and run these commands
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs
After that you can check install
$ node -v

2. MongoDB

Version >= 3.6
- More information you can check http://alendar.google.com/calendar/r?pli=1#main_7Here
-Install
Open your terminal and run these commands
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org

After that, you can check install
$ mongo -v

3. Graphicsmagick

- More information you can check http://www.graphicsmagick.org/README.html Here
- Install
Open your terminal and run these commands
$ sudo apt-get update
$ sudo apt-get install libpng12-0
$ sudo apt-get install libjpeg-dev
$ sudo apt-get install ghostscript
$ sudo apt-get install libtiff5-dev
$ sudo apt-get install libfreetype6
$ sudo apt-get install libfreetype6-dev
$ wget ftp://ftp.graphicsmagick.org/pub/Graphi ... .26.tar.gz
$ tar xzvf GraphicsMagick-1.3.26.tar.gz
$ cd GraphicsMagick-1.3.26
$ ./configure
$ make
$ sudo make install

- After that, you can check install
$ gm

4. Redis

- Install
Open your terminal and run these commands
$ sudo add-apt-repository ppa:chris-lea/redis-server
$ sudo apt-get update
$ sudo apt-get install redis-server

- After that you can check install
$ redis-cli

5. Nginx

- Install
Open your terminal and run these commands
$ sudo apt-get install nginx
- After that you can check install
$ nginx -f

6. PM2

- Install
Open your terminal and run these commands
$ sudo npm install pm2 -g

After that you can check install
$ pm2

Step 3 - Server

- API
- CD to API folder
- Create [environment].json file in the server/config folder by copy development.json file (change [environment] by your environment)
- Create file .env in the root api folder. Then copy all content into env.example file.
- Change all config by your config

#################
## environment ##
#################

NODE_ENV=production
APP_NAME=API_KERNEL
ALLOW_CORS=true
PORT=8080

## Change by your app secret
SESSION_SECRET=123141413

SITE_NAME=xchat
# API url, remember add / at the end
baseUrl=http://localhost/
logoUrl=http://localhost/assets/logo.png

# Social link or email template
facebookUrl=https://facebook.com
twitterUrl=http://twitter.com

#############
## mongodb ##
#############

MONGO_URI=mongodb://localhost/xchat-dev

#############
## redis ##
#############

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASS=
REDIS_URL=redis://localhost:6379/0

## queue
QUEUE_PREFIX=queue

############
## agenda ##
############

AGENDA_COLLECTION_NAME=agenda
AGENDA_MAX_CONCURRENCY=6

## mailing
SENDGRID_API_KEY=xxx

SPARKPOST_API_KEY=xxx

MAIL_SERVICE=sendgrid

[email protected]

[email protected]

## File size limit in MB
MAX_PHOTO_SIZE=1000
MAX_VIDEO_SIZE=200
MAX_FILE_SIZE=100

## Config for avatar. in pixel
AVATAR_SIZE_WIDTH=250
AVATAR_SIZE_HEIGHT=250

## Config for certification of model. in pixel
CERTIFICATION_SIZE_WIDTH=500
CERTIFICATION_SIZE_HEIGHT=500

## Photo size
in pixel (when uploading a new photo in media module)
PHOTO_THUMB_WIDTH=250
PHOTO_THUMB_HEIGHT=250
PHOTO_MEDIUM_WIDTH=600
PHOTO_MEDIUM_HEIGHT=600
## Background color when resize thumb image, if image is not fit, we need to fill background image here
## Color suppor transparent and color code (can check here https://html-color-codes.info/)
PHOTO_RESIZE_BACKGROUND_COLOR=transparent

## Config for s3 file
USE_S3=false
AWS_S3_BUCKET=xxx
AWS_S3_REGION=xxx
AWS_S3_USERNAME=xxx
AWS_S3_ACCESS_KEY=xxx
AWS_S3_SECRET_KEY=Txxx
## If not provided, we will get url from the bucket and region, include bucket or domain of bucket
AWS_S3_BASE_URL=https://s3-sa-east-1.amazonaws.com/your-bucket

# Information from Twilio config
SMS_FROM=+123456789
SMS_SID=xxx
SMS_AUTH_TOKEN=xxx

# Debug verify code, if live, it should null
PHONE_DEBUG=

MAX_PROFILE_PHOTO_NUM=5
COMPLETED_PROFILE_PHOTO_NUM=5

COMMISSION_RATE=0.2

FREE_TOKEN_REGISTER=50

MIN_PAYOUT_REQUEST=100

- Save all information

- Start the app by the command $ node server/www

- If you installed pm2, you can use pm2 to start the app and keep in the background. Use command $ pm2 start server/www --name=”api.yourapp.com”

- You can check IV for API folder if needed

Step 4 - Build web

- Create your application folder in www like this
Web: $ mkdir /var/www/yourapp.com/web
Admin: $ mkdir /var/www/yourapp.com/admin
API: $ mkdir /var/www/yourapp.com/api

1. Web

- Note: Must use node js 8 to build the app

- CD to web app

- Run command $ npm install to install node_modules

- Edit file config > shared.ts > environment.prod.ts file

- Change all config by your api url and services key we have. It looks like

export default {
apiEndpoint: 'https://api.yourapp.com/v1',
socketUrl: 'https://api.yourapp.com',
maxProfilePhotoNum: 5,
completedProfilePhotoNum: 5
};

- Run command $ npm run build

- After that, you will have dist and .next folder

https://i.imgur.com/k4G4ScF.png

- Upload all content in the dist folder to your web app folder in the server

https://i.imgur.com/DVCaoiM.png

Upload .next and static folder to server

https://i.imgur.com/L3PlmtR.png

- Run command $ npm install to install node_modules in server

- You can use https://filezilla-project.org/ Filezilla to upload

- Use command $ pm2 start index.js --name=”yourapp.com”

- The app will start with port 8081

2. Admin

- Same Web app

- Upload all content in the dist folder, .next folder and static folder to your admin app folder in the server

- Run command $ npm install to install node_modules in server

- You can use https://filezilla-project.org/ Filezilla to upload

- Use command $ pm2 start index.js --name=”admin.yourapp.com”

- The app will start with port 8082

Step 5 - Config nginx

- Create new config file for your app in the /etc/nginx/sites-enabled folder. Like /etc/nginx/sites-enabled/yourapp.com.conf

- Edit your config look like this

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
server {

root /var/www/yourapp.com/web;

gzip on;
gzip_proxied any;
gzip_comp_level 4;
gzip_types text/css application/javascript image/svg+xml;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
sendfile_max_chunk 512;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name yourapp.com;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8081;
}

location /_next/static/ {
alias /var/www/yourapp.com/web/.next/static/$1;
access_log off;
expires max;
}

location /static/ {
alias /var/www/yourapp.com/web/static/$1;
expires max;
autoindex off;
}


listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /path/to/ssl/admin/fullchain.pem;
ssl_certificate_key /path/to/ssl/admin/privkey.pem;
}
server {

root /var/www/yourapp.com/api/public;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name api.yourapp.com;

client_max_body_size 2000m;
location / {
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Proxy "";

# WebSocket support
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
}


listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /path/to/ssl/seller/fullchain.pem;
ssl_certificate_key /path/to/ssl/seller/privkey.pem;
}
server {

root /var/www/yourapp.com/admin;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name admin.yourapp.com;


gzip on;
gzip_proxied any;
gzip_comp_level 4;
gzip_types text/css application/javascript image/svg+xml;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
sendfile_max_chunk 512;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8082;
}

location /_next/static/ {
alias /var/www/yourapp.com/admin/.next/static/$1;
access_log off;
expires max;
}

location /static/ {
alias /var/www/yourapp.com/admin/static/$1;
expires max;
autoindex off;
}


listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /path/to/ssl/admin/fullchain.pem;
ssl_certificate_key /path/to/ssl/admin/privkey.pem;

}

- Change 8080 to your API port. Change domain, root directory in your app

- Restart your nginx $ sudo service nginx restart

Step 6- Seed data

- CD to API folder

- Run $ export NODE_ENV=production (or environment you are using)

- Open file server > migrations > user.js and change default account you want

https://i.imgur.com/K16dNWr.png

- Run $ node server/migrate

- After that default data will be generated.

Step - 7 Testing

- Open your browser and test

Web user: https://yourapp.com
Seller: https://seller.yourapp.com
Admin: https://admin.yourapp.com

- Default admin account: [email protected] with password admin

Step 8 - Other

Use pm2

Check pm2 services $ pm2 ls

Reload your api / web / admin app $ pm2 reload [app-id]

Return to “xChat V1”

Who is online

Users browsing this forum: No registered users and 2 guests