How to create a Node.js application with cPanel using the Node.js selector?

How to create a Node.js application with cPanel using the Node.js selector?

How to create a Node.js application with cPanel using the Node.js selector?

How to set up a graphical interface of cPanel along with Node.js application? Yes! You can easily set up this process by using the Node.js selector.

Most probably, we are using variables like below-mentioned:

S.NoVariable Name Description

1.​

app​

It is used in the application URL and root directory of the application.​

2.​

example​

It is used as a username​

3.​

Example.com​

For domain purpose, you can use this.​

4.​

App.js​

It is used for the file application startup.​

5.​

My app​

You can use it for description​

6.​

10 or 11​

This variable is recommended for version number used majorly in node.js​

To set up the Node.js application along with the interface of cPanel, you can follow the below-mentioned method on your choice.

Method 1:

Step 1:
Go to cPanel and then log in using the username and password. After login, check for the section “Software”.

Step 2: Tap on the option “setup node.js app” and so, it opens up the Node.js selector. Here, you need to set up the Node.js application by tapping on the option “CREATE APPLICATION”.

1611912393300.png

1611912584126.png


Step 3: It’s time to fill up the forms which display some details like mentioned below:

Node.js version: You can see the list of drop-down so, select the version based on the requirement.

Application mode: Either you can choose production or development from the shown list. We are in development mode right so tap on development first. Later, we can change the requirement for production.

Application root: The application file location is fixed here. You can check the application file added to the path /home/username.

Note: You should not use domain document root for saving application root.

Application URL: The application address is added here.

Application startup file: Whenever you launch the application along with that startup file will be processed.

1611912717511.png


Step 4: After completion, tap on the button “create”.

Step 5: Choose the option “open” for checking the test page of the application that would start automatically.

Confirm the process after getting the message “It works!”

Step 6: Start creating the package.json file. In the cPanel dashboard, go to section “file” and tap on the icon “file manager”.

Step 7: Click on the application root folder present on the left side of the file manager. To create a new file, tap on the button +file and then enter the name as package.json

Step 8: Don’t forget to click on the button “create a new file”. By now, the file will be created and make changes on the file by right-clicking the package.json file.

Step 9: You can see the option “edit” for editing the new file. Add the below-mentioned text in the editor:

"name": "app",

"version": "1.0.0",

"description": "My App",

"main": "app.js",

"scripts": {

"test": "echo \"Error: no test specified\" && exit 1"

},
Step 10: Save the file by clicking the button “save file” and then tap on the close button.

Step 11: The creation of the file is over! Next, start installing npm. Go to cPanel dashboard, choose the section “software” and then tap on the icon “setup Node.js App” to open the Node.js selector.

Step 12: Edit the application by tapping on the icon present in the column of action.

Step 13: It will start the process of running NPM installation. You will get the message as “NPM install completed successfully!”

After the installation of NPM starts installing packages too! You can perform the command line by login into SSH and then enter the virtual environment on-page of the application setup.

1611148305556.png


Method 2:

How to use the command line for setting Node.js application?


Some would prefer to use bash shell and SSH in that case they will also prefer command-line execution because it will be fast and easy to navigate. Follow the below steps to use the command line for creating a Node.js application

Step 1: Use SSH to login into the account. Start creating the application with the command as

cloudlinux-selector create --json --interpreter nodejs --version 11 --app-root app --domain example.com --app-uri app
Step 2: Here, you need to change directly to application directory:

Step 3: Now, open the editor “vi” to create a file called “package.json”.

vi package.json
Step 4: Change the mode as insert by pressing the key “i” to paste the below-mentioned text:

{

"name": "app",

"version": "1.0.0",

"description": "My App",

"main": "app.js",

"scripts": {

"test": "echo \"Error: no test specified\" && exit 1"

},

"author": "",

"license": "ISC"

}
Step 5: Now to change from insert mode into command mode press the button “enter”. Also, press the button “x” for file save and editor exist.

Step 6: Again, start installing the npm by executing the below command:

cloudlinux-selector install-modules --json --interpreter nodejs --user example --app-root app
Step 7: You can control the application in running state by restarting the application, starting the application and stopping the application.

Use below command to stop the application:

cloudlinux-selector stop --json --interpreter nodejs --app-root ~/app
Use the below command to start the application:

cloudlinux-selector start --json --interpreter nodejs --app-root ~/app
Use the below command to restart the application:

cloudlinux-selector restart --json --interpreter nodejs --app-root ~/app
We have explained the process of setup the Node.js application in the interface of cPanel using Node.js selector. The process may be a little complicated but easy to understand and implement.
Author
bhawanisingh
Views
7,715
First release
Last update
Rating
0.00 star(s) 0 ratings
Top