Blog

How to Configure and Deploy CloudLinux’s Node.js Selector

Why Node.js for CloudLinux? In the last few years, the stability and ease of use of Node.js has lead to heavy adoption in...

Written by admin · 3 min read >

Why Node.js for CloudLinux?

In the last few years, the stability and ease of use of Node.js has lead to heavy adoption in application development.  However, deploying and configuring a Node.js application to work with cPanel presents a number of hurdles. CloudLinux’s recently released Node.js Selector is a great solution that includes a graphical interface to make deployment go more smoothly. To use this utility, you will need to have CloudLinux installed along with the LVE Manager plugin. In this configuration, your Node.js application will also benefit from the resource usage monitoring that comes with the CloudLinux LVE Manager.

Step 1 – Installation of Phusion Passenger

We’ll need to enable Phusion Passenger for EasyApache. In Web Host Manager, navigate to EasyApache.  From there, in the upper left corner of the screen type in “EasyApache 4”.  Select “Customize” in the menu that follows and then “Apache Modules”. In the list of Apache modules searching for “Passenger” will bring up the option to install mod-alt-passenger as shown below:

After selecting mod-alt-passenger, all that needs to be done is to skip to the “Review” step on the left sidebar and click “Provision” on the review menu to apply the changes.

Step 2 – Installation of CloudLinux Node.js Selector

To start the installation of Node.js Selector for your users, proceed to the LVE Manager page in Web Host Manager. Under the Options tab, click on the Node.js line to expand the section containing the install menu for the various Node.js versions:

Only the Node.js versions installed here will be available for each cPanel user. So for each Node.js version, first click “Install” to put in place the needed packages. Then, select the “Enable” switch for each version of Node to make it available. Once each version you would like to use is installed and enabled, be sure to also enable the overall toggle switch where it says “Node.js” to make the system available for your users.

 Post-installation,  with everything in place, the install menu should look like this:

Step 3 – Web Host Manager (WHM) Configuration:

At this point, you’ll have the LVE Manager configured, as well as Node.js setup for your cPanel users. However, the default cPanel memory limit is sometimes insufficient to install Node.js packages using NPM.  It is recommended to increase this memory limit to avoid issues during deployment. To make the change in WHM, proceed to the “Tweak Settings” page, and search for “Max cPanel process memory”.  Increase this from the default of 768MB to at least 1024MB to avoid issues with the NPM installer.  This setting does not affect the memory allocated to a Node.js application, but it does allow for the initial installation of Node.js packages to make use of additional memory needed for dependency resolution. Once the change is made, the Tweak Settings page will show the updated limit in the System section:

Step 4 – Version Control with Git

Before we can configure your Node.js application, the first step is getting that application on your server. There are a few options. You can use FTP to upload the copy of your application to your server, or you can use cPanel’s native Git support to clone the repository onto your server and deploy from there. Either method meets the requirement to get the application onto the server. In this example, we’ll be using cPanel’s native Git support to clone the application onto your server and then deploy it.

Within the cPanel user account that you’d like to host the application on, under the “Files” tab, select the “Git Version Control” option. This will bring you to a page where you can create a Git repository. In this example, we’ll be using the https://github.com/socketio/chat-example repository to deploy a simple chat application.

To keep your application data secure be sure not to clone or upload into the public_html folder since this makes the code itself potentially accessible from the web. CloudLinux strives to keep your data safe, and during deployment, it’s not a requirement that your application data be publicly accessible.

Here’s an example of the Git page, before the clone is completed.

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 save that path for later.

Step 5 – Application Configuration

With the application files in place on the server, we 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.

Notes on Choosing Development vs. Production:
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.

Bitcoin Exchange Script

admin in Blog
  ·   1 min read

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *