This module will disable Apache's mod_userdir module.
It is recommended that the hosting provider install the ea-ruby27-ruby-devel
Here's how you can install the application:
Step 1: Log in to the server via SSH as a cPanel user
Step 2: You need to create the application's directory relative to your home directory.
To do that, you need to run this command - mkdir nodejsapp
Step 3: Now, change the application's directory. Besides, it would help if you created app.js with a text editor.
Because Passenger searches for this filename when it executes, we strongly advise you to build it with this exact name. If you are creating a startup file with a different name, you must mention the filename in the 'httpd.conf' file. Then, follow the Create a custom startup file instructions below.
Step 4: Add the configuration of the application to the app.js file.
You can prefer the following example:
const http = require('http')
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World! NodeJS \n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
If you want to test the application follow the following steps:
Step 1: Log in to the server via SSH as a cPanel user and run the command
-> /opt/cpanel/ea-nodejs16/bin/node app.js
You can prefer this for the output:
-> Server running at
http://127.0.0.1:3000
Step 2: Open another window, try logging in to the server via SSH with the same cPanel user.
Step 3: Run the command
-> curl
http://127.0.0.1:3000
You can prefer this for the output:
-> Hello World! NodeJS
Step 4: You have to stop the testing process by ctrl + c in the window, or you can run the following command
-> ps aux | grep app.js
Step 5: This will produce a list of running programs' pid (process ID) numbers that include the script name. Run the following command to terminate the test application, where PIDNUMBER is the process ID:
-> kill -9 PIDNUMBER