Streamnow: Prerequisites For Installation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

StreamNow

Prerequisites for Installation:

❏ Digital Ocean account


❏ Terminal/Command prompt
❏ Lamp install
❏ Node install
❏ NPM install
❏ Tmux
❏ Cron Job
❏ Project Setup

Note: Installation on ubuntu 18.04.


Server Setup and Installation:

STEP 1:
After logging into your account, It will take you to the Droplets(server) page, Click
on Create Droplet.

STEP 2:
Once you click on create droplet, select the ubuntu server and we will be needing
a minimum of $10 bandwidth for running a proper streamnow service.
STEP 3:
You can leave the other options unchecked and scroll down to end. Specify a
hostname if you want and Click create to finish creating a droplet.

STEP 4:
Once a droplet is created, you will get a mail to your account with a root
password and confirmation for creating a droplet. You can revert back to the
digital ocean account and find the droplet details listed with IP address.

STEP 5:
After having these details, You can open your Terminal/Command
prompt(Terminal 1) and Type in the following command :
Open the server without SSH-KEY using this command.

ssh root@DROPLET_IP_ADDRESS

Open the server with SSH-KEY using this command.

ssh -i root-ssh-private-key root@DROPLET_IP_ADDRESS

It will prompt you for a password, enter the root password that was sent to your
mail and press Enter. It will show details of your server and log you in.
STEP 6:
Now that you have logged into your server from terminal, we’ll have to create an
alternate user account that you can use to access. From the logged in terminal,
type in the following command:

adduser DESIRED_USERNAME

STEP 7:
This would have created a User account. Now let’s add admin privileges to this
Account by typing the following command :

Usermod -aG sudo DESIRED_USERNAME

Please use the username you selected in STEP 6 for this.

STEP 8:
For creating a secure server, we have to create a security key for your local
machine. Let’s do that by Opening a new terminal window(Terminal 2) and
typing in the following command:

ssh-keygen

Once you type this command, It will prompt you for a question, Hit Enter without
typing anything. It will ask again for a passphrase, Hit Enter without typing
anything. Now your key is created.

STEP 9:
Now we’ll have to copy the key. To display the key, type in this command:

cat id_rsa.pub
id_rsa.pub - What you give the key name for public key.
The key will be a long sequence. Once the key is displayed, select it and copy it
using your Mouse or cursor.

STEP 10:
Let’s add this public key to our user (switch to TERMINAL 1) by typing in the
following commands in sequence :

su - USERNAME
mkdir .ssh
chmod 700 .ssh
nano .ssh/authorized_keys

This will open up a blank file in your Server terminal. Paste the copied ssh key in
this and press “ctrl/cmd+x”, it will prompt a question. Type Y and press enter
again.

chmod 600 .ssh/authorized_keys


exit

STEP 11 (Optional):
To not allow default root login and secure the server ssh daemon, type in the
following command from logged in Terminal 1 from the root folder :

nano /etc/ssh/sshd_config

This will open up the file. Now search for the line “PermitRootLogin Yes” and
change it to “PermitRootLogin no” . Once this is done, let’s restart the ssh service
by typing in this command:

service ssh restart


STEP 12:
Now let’s close up all our terminals, Open a fresh new Terminal and try
connecting to the server.

ssh -i ssh-key USERNAME@DROPLET_IP_ADDRESS


(Example)
ssh -i id_rsa [email protected]

STEP 13:
Now we’ll have to install apache for our servers to run. We can do that by typing
these commands in the terminal after logging in as the new user.

sudo apt-get update


sudo apt-get install apache2

Type in your password when it asks for it. Let each command run and take it’s
time.

STEP 14:
To verify if it’s working or not, you can just open your browser and type in the
droplet IP address as the url and check if the Apache Ubuntu page is shown. Now,
let’s install our database MySQL. Type in the following command from the
terminal:

sudo apt install mysql-server

sudo mysql_secure_installation

sudo mysql

SELECT user,authentication_string,plugin,host FROM mysql.user;


ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY
'UPDATE_YOUR_MYSQL_PASSWORD;

FLUSH PRIVILEGES;

SELECT user,authentication_string,plugin,host FROM mysql.user;

exit

STEP 15:
For our script to work, we need php script to run. So let’s install PHP on our server
with the most needed Mcrypt plugin. Type in the following command:

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt install php7.4

sudo apt-cache search php7.4

sudo apt install php-common php-mysql php-xml php-xmlrpc php-curl


php-gd php-imagick php-cli php-dev php-imap php-mbstring
php7.4-opcache php-soap php-zip php-intl php-fpm

Change the Upload limits php.ini file

sudo nano /etc/php/7.4/apache2/php.ini


Change the below values
max_execution_time=-1
max_input_time=-1
memory_limit -1
post_max_size = 3000M
upload_max_filesize = 2048M
STEP 16:
Now that php is installed, we want our server to look for Index.php first than
index.html in order. So let’s change that by opening up this server file. Type in the
following command:

sudo nano /etc/apache2/mods-enabled/dir.conf

This will open up a file that has information like this.

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
index.htm
</IfModule>

Change it to,

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml
index.htm
</IfModule>

STEP 17:
Let’s restart the service and check to see if the process has gone correctly. Type in
the command :

sudo service apache2 restart

And that’s it for installing PHP,MySQL and apache.


STEP 18:
Let’s set up phpMyAdmin now for accessing our Databases. Type in the command
in the terminal :

sudo apt-get install phpmyadmin php-mbstring php-gettext


sudo phpenmod mbstring

This will prompt a few questions to make the installation correctly. When the first
prompt appears, Hit “SPACE”, then “TAB” and “Enter” . After this, you will be
asked for a database administrator’s password. Next, you will be able to choose
and confirm a password for the phpMyAdmin application itself.
STEP 19:

After enabling the mcrypt extension, restart apache service.

sudo service apache2 restart

Open the apache conf file . Eg: sudo nano /etc/apache2/apache2.conf

Change to the following lines.

<Directory />
Options FollowSymLinks
AllowOverride None -> Change None to All
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None -> Change None to All
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None -> Change None to All
Require all granted
</Directory>
Update the end of the file in this command. After saving the apache2.conf file
restart the apache2.

Include /etc/phpmyadmin/apache.conf

sudo service apache2 restart

STEP 20:
Now you can access phpMyAdmin by typing in your web browser URL
“http://DROPLET_IP_ADDRESS/phpmyadmin”. Once the page opens, you will be
asked for a username and password. Use “root” for username and the password
you set during phpMyAdmin installation for password and login. You will be able
to create/delete databases in your server now.

As of now, all the basic requisites are installed in our server including, php, Mcrypt,
MySQL, phpMyAdmin and we have set up a user account for secure access from
our local machine.

STEP 21:
Download the Streamnow package zip file. Now we have to put this code in our
server that we have set up till now. Since we added a secure user and secure
access to our server, we don’t have to use a separate FTP client, we can use a
secure copy method. Open a new terminal, do not log in to the server, just type
this command :

scp -r -i id_rsa(ssh_key path) PATH_FOR_STREAMNOW_PACKAGE


USERNAME@DROPLET_IP:/home/USERNAME

id_rsa - whatever you create a ssh key that private key path name

Note : “Path for streamnow package” means the path your downloaded package
is, eg: C:/Users/PC name/Downloads/streamnow
After this, You will have the streamnow backend and frontend zip file in your server.
Unzip the both file for using the this command.

sudo apt-get install unzip

unzip streamnow-backend.zip

unzip streamnow-frontend.zip

unzip streamnow-mobilestreaming.zip

STEP 22:
You will get 3 different folder
1. streamnow-frontend
2. streamnow-backend
3. streamnow-mobilestreaming

streamnow-frontend - It contains only react js code - user panel.


streamnow-backend - It contains API ‘s and Admin panel.

Once this command is typed, it will ask you for the password, type in the
password and press enter to securely copy all the code into our server. First, Login
to the server using ssh username@droplet_ip_address command and sublink all
the other folders to the root folder by typing in this command.

sudo ln -sf /home/USERNAME/streamnow-backend /var/www/html

STEP 23:
Please let each command in this step to take its time to download node JS and
execute the plugins. Once each command finishes, type in the next one.

# Composer Installation: ( Optional )


sudo apt-get install composer
cd streamnow-backend

composer update

STEP 24:
# TMUX Installation:
We need to configure the tmux session. So that we can have multiple sessions on
the server. Let’s start configuring tmux session.

cd ~
wget https://aravinth.net/tmux.conf --no-check-certificate
mv tmux.conf ~/.tmux.conf

Open the bashrc file using below command,

sudo nano ~/.bashrc

Paste this in bottom of the File

tm() { tmux new -s "$1" ;}


ta() { tmux attach -t "$1"; }
tl() { tmux list-sessions; }

Run this command

source ~/.bashrc
tm session_name ( Create New Session )

List All Session

tl

Open already existing session

ta session_name
STEP 25:
# NPM and NODEJS Installation
Next we need to install nodejs and npm on this server.

cd streamnow-backend/
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install build-essential

# Node Modules Install ( Optional )


cd streamnow-backend/
npm install
cd streamnow-nodejs
npm install

After installing the npm and nodejs, the node_modules folder will be created in
the backend folder and streamnow-nodejs folder.

STEP 26:
We’ll have to create a database using phpMyAdmin. So open up a web browser,
Type in the URL field : http://DROPLET_IP_ADDRESS/phpmyadmin and Log in
using the username as root and the password you gave during installation.

After logging in, Click on the “Databases” tab, enter a desired database
name(Remember this database name) in the “create database” field and click on
create database to create an empty database.

Once you’ve created an empty database, Click on the “Import” tab and click on
“choose file” button. Now, locate the “Eg: streamnow.sql” database file inside
the DB folder from the downloaded package and import it into the empty
database. You can see a list of tables now on your left pane after import.
STEP 27:
Now from the server logged in terminal, type this following command to go into
the streamnow-backend directory :

# .env File Configuration


cd streamnow-backend

Open up the .env file using this following command :

sudo nano .env

After opening up the file, find the following piece of code and give the correct
information.

APP_URL= (Provide your ADMIN URL here)


DB_HOST= 127.0.0.1 (Provide Database host here, default host is 127.0.0.1)
DB_PORT= 3306 (Provide Database port here, default port is 3306)
DB_DATABASE= (Provide the Database name that was created in STEP 28)
DB_USERNAME= (Database username provided during configuration)
DB_PASSWORD= (Database password provided during configuration)

And for mailer integration, (we are using simple SMTP gmail server)

MAIL_USERNAME= (Provide your gmail username)


MAIL_PASSWORD= (Provide your gmail password)
QUEUE_DRIVER=database

SSL Configuration

SSL_KEY= ( Provide KEY PATH )


SSL_CERTIFICATE= ( Provide CERTIFICATE PATH )

Reinitialize the .env changes to cache

php artisan config:clear


php artisan cache:clear
php artisan config:cache
php artisan storage:link

STEP 28:
We need to give permission - navigate to /streamnow-backend/ - you can find
storage,public/uploads, bootstrap/cache. Give 777 permission.

sudo chmod -R 777 public/uploads bootstrap/cache storage .env

# Folders Creation - (Optional)

If you get any error in image uploading from your site do this command.

Create an empty folder from inside the public/uploads folder.

cd streamnow-backend/

mkdir public/uploads public/default-json

cd public/uploads

mkdir admin videos users site images user_chat_img rooms sdp_files


streamer_gallery

STEP 29:

# Cron Job Update


Cronjob used to update the subscription auto renewal and video handling

cd /home/USERNAME/streamnow-backend
sudo crontab -e

Update the end of the line


0 0 * * * curl --request GET 'https://ADMIN-URL/cron_delete_video'

0 0 * * * curl --request GET 'https://ADMIN-URL/remainder-for-subscription'

0 0 * * * curl --request GET 'https://ADMIN-URL/user_payment_expiry'

#Project Setup
Once everything is configured. We need to start a queue and npm. Open tmux
new session.
Go to streamnow-backend code which will be

1. Open tmux session ( ta session_name)

2. First window - follow the below commands ( Queue start )

cd streamnow-backend
php artisan queue:listen --timeout=0 --tries=2

3. Second window - follow the below commands ( NPM for chat start )

cd streamnow-backend
npm start

Note: HTTPS website or SSL configured from your site

If your website is SSL configuration means follow this steps

cd streamnow-backend

sudo nano .env

SSL_KEY=

SSL_CERTIFICATE=

Update the ssl details from here end file.This line you will be
find.remove the example key and crt and update your admin ssl key and
crt

In this SSL details where you can get means go to you SSL virtual host admin
domain configuration file. There you get the ssl key and CRT.
After this steps complete save the file start the npm - use commands npm
start
If you are using letsencrypt SSL means use this commands from your website

cd streamnow-backend/
sudo npm start

4. Third Window - follow the below commands ( Npm for WebRTC Live

stream start )

cd streamnow-backend/streamnow-nodejs
npm start

Note: HTTPS website or SSL configured from your site

If your website is SSL configuration means follow this steps

cd streamnow-backend/streamnow-nodejs

sudo nano config.json

var isUseHTTPs = false; //change the false to true

"sslKey": "./fake-keys/privatekey.pem",
"sslCert": "./fake-keys/certificate.pem"

Change to

"sslKey": "Update here admin domain SSL key path",


"sslCert": "Update here admin domain SSL CRT path"

After this steps complete save the file start the npm - use commands npm
start
If you are using letsencrypt SSL means use this commands from your website

cd streamnow-backend/streamnow-nodejs
sudo npm start

Don’t close the tmux session queue listen has to run in background
continuously.
control + b d // To exit from tmux session without closing it.

STEP 30:
We’ll have to configure the Frontend website. Please follow the below steps,

# Basic setup for frontend ( OPTIONAL)


cd ~
cd streamnow-frontend
sudo npm install

# Configure the Base url


Please change the following details.

Update the details like below,


apiUrl: ‘https://admin.domain.com/api/user/’

sudo nano src/Environment.jsx

# Generate Build for frontend


Navigate to our frontend folder /home/USERNAME/streamnow-frontend/
Now generate build command

cd streamnow-frontend
npm run build --prod

STEP 31:
We’ll have to create a symlink for streamnow-frontend as well.

sudo ln -sf /home/USERNAME/streamnow-frontend/ /var/www/html


STEP 32:
We’ll have to configure the Mobile website. Please follow the below steps,

# Basic setup for mobilestreaming


cd ~
cd streamnow-mobilestreaming
sudo npm install

# Configure the Base url


Please change the following details.

sudo nano src/Environment.jsx

Change the const api Url = https://admin-streamnow.com/ (Backend Url)

sudo nano src/components/broadcastPage/BroadcastIndex.jsx

Change the Url to Frontend Url


connection.socketURL = "https://streamnow.com:9001/";

# Generate Build for mobilestreaming


Navigate to our frontend folder /home/USERNAME/streamnow-mobilestreaming/
Now generate build command

cd streamnow-mobilestreaming

sudo npm run build --prod

sudo cp https_htaccess build/.htaccess

STEP 33:
We’ll have to create a symlink for streamnow-mobilestreaming as well.
sudo ln -sf /home/USERNAME/streamnow-mobilestreming/ /var/www/html

STEP 34:
We’ll have to create a virtual host for user panel and admin panel and also for the
mobilestreaming panel.

Open the virtual host in path


cd /etc/apache2/sites-available

sudo cp 000-default.conf frontend.conf

sudo cp 000-default.conf mobilestreaming.conf

Open the 000-default.conf and update the server name and document root -
backend configuration

sudo nano 000-default.conf

ServerName backend-domain.com -> comments: remove # this

ServerAdmin webmaster@localhost -> comments: Update the you admin


email (optional)

DocumentRoot /var/www/html/streamnow-backend/public -> comments:


update the root directory

Save the 000-default.conf file.


Open the frontend.conf and update the server name and document root - frontend
configuration

sudo nano frontend.conf

ServerName frontend-domain.com -> comments: remove # this

ServerAdmin webmaster@localhost -> comments: Update the you admin


email(optional)

DocumentRoot /var/www/html/streamnow-frontend/build >> comments:


update the root directory

Save the frontend.conf file.

sudo nano mobilestreaming.conf

ServerName frontend-domain.com -> comments: remove # this

ServerAdmin webmaster@localhost -> comments: Update the you admin


email (optional)

DocumentRoot /var/www/html/streamnow-mobilestreaming/build >>


comments: update the root directory

Save the mobilestreming.conf file.

Here is the reference link to create a virtual host.

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-
hosts-on-ubuntu-14-04-lts

After this process is complete do the following commands.

sudo a2ensite frontend.conf


sudo a2ensite mobilestreaming.conf
sudo a2enmod rewrite
sudo service apache2 restart

STEP 35:
This completes the server setup and installation for Streamnow. Now please open
up a browser and type in the URL : http://admin.domain.com and login with the
default username and password.

Admin Demo Logins:

URL: https://admin.domain.com/admin/login

Username : [email protected]
Password : 123456

Streamer Demo Logins:

URL: https://domain.com/

Username: [email protected]

Password: 123456

Viewer Demo Logins:

URL: https://domain.com/

Username: [email protected]

Password: 123456

STEP 37:
Once the installation is completed - you need to configure webrtc socket url, chat
url, chat socket url, Frontend URL in admin panel -> Settings -> video settings.

STEP 38:
Installation is complete. Browse around and check all features.
Start making money and invite us for your launch party :)

IMPORTANT : If you are having trouble making the installation, you can always
opt for our premium installation package for just $79. This way, you can relax and
we will get back to you with admin access to your Streamhash venture,You can
reach us at [email protected] for further queries or talk to us on live chat
at StreamHash.

You might also like