Node.js is mainly used for hosting different kinds of applications like the Ghost blogging platform etc.
This open-source cross-platform environment allows for rapid development of applications, which leads to high productivity, and therefore quicker deployment. Hosting Marketers now provides NodeJS support within our shared hosting servers, and you can create/manage applications easily via your hosting cPanel control panel interface.
How to Install a Node.js Application Using Node.js Selector
Node.js Selector is a CloudLinux component (that we provide on all our hosting servers) that allows each user to easily create Node.js applications, choose Node.js version and other parameters for applications based on their needs. With a friendly UI (our cpanel), it unites all of the features in one place and makes it very convenient to manage.
At the time of writing this, Node.js Selector supports Node.js versions 6.x, 8.x, 9.x, 10.x.
The Node.js Selector has many advantages over manual deployment.
It allows for several different applications to be run under the same user, accessed under the “Setup Node.js App” page in your cPanel account.
With Node.js Selector, all these handled for you.
To start, go to cPanel → Software Section → Select Node.js Version.
The Web Applications page will be displayed and you will see several columns in the list.
App URI: application URI including the domain.
App Root Directory: application root directory relative to the user’s home.
Mode: can be production or development.
Status: started/stopped — displays if an application is running or not and version of the application.
Actions: allows to start, restart, stop, edit, and remove a particular application.
How To Create A Node.js Application
Before you can configure your Node.js application, you will need to get that application to your cPanel server.
You can simply use FTP to upload the copy of your application to your server.
Or you can also use cPanel’s native Git support to clone the repository onto your server and deploy from there.
The following example below used cPanel’s native Git support to clone the application to the server and then deploy it.
Clone The Application with Git
Go to GitHub and copy the URL of the repository to clone
copy the url, in this example I will use the Ghost a publishing platform.
Now go back to cpanel and click on Git™ Version Control
A new page comes up to install the new git, re-enter the url
the the repository Path and repository name will show automatically.
click create again. Now it is done, copy the repository path, in this case
save this path you going to need to install the node. if you finished this step of the repository then go to “Back now to the node” but if using your own private repository on GitHub then continue reading below.
Cloning To A cPanel Server From A Private Github Repo
Private repos require SSH access, open a ticket with customer support and ask them to enable shell access. You can use cPanel’s Terminal interface (cPanel – Home – Advanced – Terminal) to access the command line from within the cPanel interface.
Generate An SSH Key
If you have not already configured one, run the following command to generate an SSH key:
ssh-keygen -t rsa -b 4096 -C “firstname.lastname@example.org”
In this example, “username” represents the cPanel account username and “example.com” represents the domain name.
After you run this command, the system will prompt you to enter a passphrase.
Do not enter a passphrase.
Press Enter to continue.
Verify That The Key Is Available
To confirm that the key exists and is in the correct location, run the following command:
Register our SSH Key With The Private Repository Host
To register an SSH key with GitHub, perform the following steps:
Log in to your GitHub account. Navigate to your private repository. In the top right corner of the page, click Settings. A new page will appear. In the left side menu, click Deploy keys. A new page will appear. In the top right corner of the page, click Add deploy key. A new page will appear. Enter your SSH key data: In the Title text box, enter a display name for the key. In the Key text box, paste the entire SSH key. If you want to push code from your cPanel account to your GitHub account, select the “Allow write access” checkbox.
If you do not select this checkbox, you can only deploy changes from your GitHub repository to the cPanel-hosted repository.
Click Add key.
Do note that some repository hosts do not allow you to configure write access for your access keys.
For information about how to register your SSH key with another private repository host (Bitbucket, GitLab, etc), consult that host’s website or documentation.
Test Out The SSH Key
To test your SSH key, run the following command.
ssh -T email@example.com
where “example.com” represents the private repository’s host – e.g ssh -T firstname.lastname@example.org.
Clone The Repo To cPanel
To clone the repository, run the following command on the cPanel account, where “git clone email@example.com:$name/private-repo.git” represents the private repository’s clone URL:
git clone firstname.lastname@example.org:$name/private-repo.git
If you see “Error: The WebSocket handshake failed at …” when you access cPanel’s Terminal interface (cPanel – Home – Advanced – Terminal), recheck your connection.
If you are using VPN, disconnect and use your normal internet connection.
Once you click on “Create” this will bring you back to the repository page showing the full path of the application being deployed.
This page is important, so do save that path for later use.
Back now to the node:
cPanel → Software Section → Select Node.js Version
1- Select a Node.js version. 2- Select either “Development” or “Production” for the application mode. 3- Select the application root. The path that we save before on the Git repository.
4- Select the Application URL. This is an HTTPS link to your application. 4- Fill the form to point to the Application startup file. In this case the Ghost the file is index.js
You can also add additional Environment variables by clicking on the “Add Variable”. 5- Click Create.
… a more detailed explanation, below:
Node.js Application Configuration With the application files in place on the server, you are ready to configure Node.js to launch that application from the web.
From cPanel on the same account under the “Software” tab, select “Setup Node.js App”.
On this setup screen, you’ll select “Create Application” to bring up the options for choosing the Node.js version as well as whether to use a Development or Production environment.
Development generally has different application hooks in the code of the application, depending on how this environment variable is set.
As a general rule, Production is going to have more levels of caching, as well as minimal logging.
So, for a Development environment set, you can expect the inverse, with fewer levels of application caching, and more verbose logging and error message output.
A typical example would be where in production, you may only see an error page.
In development, you may see a full stack trace on an application error which allows you to figure out exactly where the error took place inside the code.
Since Node.js applications, in general, depend on several environment variables, you can add these using the “Add Variable” button near the bottom right of the page.
The Node.js production or development variable is already set separately in the top section using the “Application Mode”, so it is not necessary to set it again in the Environment variables section.
This same menu is where you can select the version of Node.js that you’d like to use as well as the application’s startup file.
This might be index.js, app.js or any number of variations; it depends on the application.
Once you’ve saved your application, you’ll need to resolve its package dependencies.
The NPM package manager does this automatically based on the package.json file packaged with the application, so all that you’ll need to do here is click on the ‘NPM Install” button.
At this point, you will require your domain to resolve to an IP address, or the installation script will have an error.
If you are using a sub-domain, make sure that this has been created and that you have added all relevant records to your DNS.
You can confirm this by simply running:
$ dig sub-domain.com
NPM will read the contents of the package.json file and install the needed packages into a virtual environment specific to the application.
If you are familiar with the command line, you can follow the instructions at the top of the page to gain access to the “npm” and “node” commands to make additional changes manually, allowing for a great deal of customization.
Node.js Application Deployment
By this point, you’ll have your application configured and Node.js modules installed, so you’re ready to launch the application.
Our cPanel systems make this very easy.
On the same page where you configured your application, click
“Run JS Script”
This will execute the application startup file that you defined earlier during setup.
As Node.js applications have several different options, this can bring up another menu with different options to select depending on the application that you’re running.
In general, you’ll want to select the “Start” option next. Attention that it can take some time so wait awhile.
Finally, you can select the “Open” option to visit your page, and see your application!
How To Start A Node.js Application
To start a stopped application do the following:
Click Start icon in the Actions column in a stopped application row.
When the action is completed, a Start icon changes to Stop icon.
How To Stop A Node.js Application
To stop a started application do the following:
Click Stop icon in the Actions column in a started application row.
When the action is completed, a Stop icon changes to Start icon.
How To Start A Node.js Application
To restart the application do the following:
Click Restart icon in the Actions column in a started application row.
The current row will be blocked and will be unblocked when the process is completed.
How To Remove A Node.js Application
To remove the application do the following:
click the “Bin” icon in the Actions column in a particular application row.
in the confirmation, pop-up click Agree to start removing or Cancel to close the pop-up.
When the action is completed, an application will be removed from the Web Applications table and a confirmation pop-up displayed.
How To Edit Your Node.js Application
To edit application do the following:
Click Pencil icon in the Actions column in a particular application row.
An application tab will be open.
At the moment, you can:
restart application – click Restart button.
stop Node.js — click Stop Node.js button.
remove application — click Delete button and confirm the action in a pop-up.
change Node.js version — choose Node.js version from a drop-down.
change Application mode — choose application mode from a drop-down. Available modes are Production and Development. specify Application root — specify in a field a physical address to the application on a server that corresponds with its URI.
specify Application URL — specify in a field an HTTP/HTTPS link to the application.
specify Application startup file — specify as NAME.js file.
run npm install command — click Run npm install button to install the package(s) described in the package.json file.
add Environment variables — click Add Variable and specify a name and a value.
How To Debug Errors On Your Node.js Application
Directives such as PassengerFriendlyErrorPages and PassengerAppEnv are available for use from a .htaccess file.
This allows cPanel users to debug a Node.js application during development.
For example, if you add one of the following lines to the .htaccess file on the application page and there is an error, you will see the error listed:
How to setup DMARC on cpanel? it is actually very easy and I will show you how to do it in less than a minute.
First what is DMARC and what is the use of it. Nowadays with some spam if you serious about sending your emails to your customers it is a must to have a DMARC record.
DMARC Records are published via DNS as a text(TXT) record. They will let receiving servers know what they should do with non-aligned email received from your domain.
Domain-based Message Authentication, Reporting, and Conformance (DMARC) is a mechanism for improving mail handling by mail-receiving organizations. The ultimate purpose of DMARC, according to RFC-7489 is to provide a “mechanism by which email operators leverage existing authentication and policy advertisement technologies to enable both message-stream feedback and enforcement of policies against unauthenticated email. Email originating organizations utilize DMARC in order to express domain-level distribution policies/preferences for message validation, disposition, and reporting.
How DMARC Works:
DMARC adoption has risen dramatically and has a positive or negative impact on your email deliverability. All of the major email providers support DMARC. By some measures, 80% of mailboxes worldwide are protected by DMARC.
DMARC dramatically improves on SPF and DKIM by letting you:
1- Monitor, detect and fix real world problems with your SPF and DKIM configuration 2- See the email volumes you’re delivering to inboxes 3- Identify threat emails pretending to come your domain. (Spoofing) 4- Control the delivery of your email and defend against spoofing attacks.
Now how to setup it up on your cpanel. Login to the cpanel and then click on Zone Editor then Select a domain, it will show you the list of records already available, for example subdomains if you already added to your cpanel, click Add Record, you will see a blue-highlighted field where you can add a record.
HTTP Live Streaming (HLS) is here to stay, it works everywhere, high quality and stability, but latency or delays between the stream and the end user can be 60-90 seconds, if you streaming live events that can be a very big issue, imagine Sports betting? But with Wowza Streaming Engine it is possible to reduce the latency to 3 to 5 seconds. It is not good enough but for now there is no other solution.
Below we have some adjustments that using the Wowza Streaming Engine Manage, we can easily improve, although of course there are some negative components.
This risks inherent of the configuration adjustements are due to smaller chunk sizes may result in playback errors if you fail to increase the number of seconds built into the playlist. If a stream is interrupted, and the player requests the next playlist, the stream may be interrupted when the playlist doesn’t arrive.
Additionally, by increasing the number of segments that are needed to create and deliver low-latency streams, you also increase the server cache requirements. To alleviate this concern, ensure that your server has a large enough cache, or built-in elasticity. You will also need to account for greater CPU and GPU utilization resulting from the increased number of keyframes. This requires careful planning for load balancing, with the understanding that increased computing and caching overhead incurs a higher cost of operation.
Lastly, as chunk sizes are smaller, the overall quality of the video playback can be impacted. This may result into either not being able to deliver full 4K video to the player, or small playback glitches with an increased risk of packet loss. Essentially, as you increase the number of bits (markers on the chunks), you require more processing power to provide smooth playback; without it, you get packet loss and interruptions.
A- In Wowza Streaming Engine Manager, click the Applications tab and then click live in the contents panel.
On the details page Properties tab, click Cupertino Streaming Packetizer in the Quick Links bar.
In the Cupertino Streaming Packetizer area, click Edit, and change the values for the following properties:
1- cupertinoChunkDurationTarget- Set the duration of each chunk in milliseconds. The default value is 10000, but the chunkDurationTarget must be smaller to reduce the latency of Apple HLS streams. For a one-second chunk size, set the value to 1000.
2- cupertinoMaxChunkCount- Sets the maximum number of chunks Wowza Streaming Engine stores in the available chunk list. The default value is 10, but for reduced latency streaming we recommend storing 50 seconds worth of chunks. For one-second chunks, set the cupertinoMaxChunkCount to 50; if you’re using half-second chunks, the value should be doubled (100).
3- cupertinoPlaylistChunkCount- Sets the number of items returned to the player in the playlist. The default value is 3, but for reduced latency streaming we recommend returning 12 seconds of data to the player. This prevents the loss of chunks between chunklist requests. For one-second chunks, set the cupertinoPlaylistChunkCount to 12; if you’re using half-second chunks, the value should be doubled (24).
B- On the Properties tab, click Customin the Quick Links bar.
In the Custom area, click Edit.
Click Add Custom Property, specify the following custom property settings in the Add Custom Property dialog box, and then click Add:
1- In Path, select /Root/Application/LiveStreamPacketizer.
2- In Name, enter cupertinoMinPlaylistChunkCount.
3- In Type, select Integer.
4- In Value, specify the minimum number of chunks required before Wowza Streaming Engine provides a playlist to the player. The default value is 1, but for reduced latency streaming we recommend requiring a minimum of 6 seconds worth of chunks. For one-second chunks, set the cupertinoMinPlaylistChunkCount to 6; if you’re using half-second chunks, the value should be doubled (12).
Click Save and restart the application to apply the changes.
Done, try now. Or just contact Hosting Marketers and order our RTMP Wowza with our shared hosting Wowza Engine.
Real-Time Messaging Protocol or RTMP was developed originally by Macromedia, which then became Adobe. It was a system to implement streaming of video, text and audio over the internet between a flash player and a server with the RTMP setup.
Using fragments between the server and the user, it maintains a stable connection and because of that it has low latency, meaning that there is a very short delay, between the server and the user. The delay is perhaps 1 or 2 seconds.
The RTMP servers available are Adobe Media Server, Red5, Wowza Streaming Engine, Nginx RTMP server and a few more, but this 4 are the most common, although Adobe is very expensive and Red5 is difficult, personally I prefer Wowza RTMP, which has a number of advantages, we will talk about this on another post.
Going back to RTMP, it is a TCP-based protocol which maintains persistent stable connections and allows low-latency communication. To deliver streams smoothly and transmit as much information as possible, it splits streams into fragments, and their size is negotiated dynamically between the client and server.
RTMP servers are ideal for live streaming but also for Ondemand video streaming, it is also a necessary component for live video chats.
RTMP Server, how it works
The server must be setup with a media server, like Adobe or Red5, then the video stream connects to the RTMP installed on the server, the video stream could be a laptop with a software installed, this software is an encoder, there are a number of them, OBS Studio, but the most common is the Adobe, FMLE, which you can download free at http://hosting-marketers.com/flashmedialiveencoder_3.2_wwe_signed.msi (for windows computers, Mac computers you can download directly at Adobe site.)
On the encoder you enter the server RTMP, which would be something like this:
Then you connect and start the broadcast. this stream will go directly the RTMP server and you can now setup a player for your users, if you using a RTMP player you will need to use a flash player, but using Wowza Streaming Engine on the RTMP server it converts the stream to a HLS protocol which can be used on many other platforms as well, like smartphones and HTML5 Players. Although the HLS has the latency issue because of the flash players end of live it is nearly impossible not to use it. Nowadays, with a good configuration you can reduce the latency to 3 or 4 seconds.
So we have, YOU on your laptop with a camera and an encoder >>> your internet connection and the RTMP Server connection >>> and finally the player on your site broadcasting your live event. Or your video files.
Important updates, news, reviews of our customers sites and tricks for common problems…