Install node.js?
I would like to install node.js on my cPanel & WHM v102.0.11 server with CentOS v7.9.2009. What is the best way to do this? I have seen but it tells me nothing of value.
I want to program and run node.js applications.
-
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 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 0 -
Thanks! 0 -
Did this work out for you? It seems fine for just the basic test application started with /opt/cpanel/ea-nodejs16/bin/node app.js and running on 127.0.0.1, but I'm not having any luck getting the Application Manager to register things that will actually work (i.e. the base application URL does nothing when typed into a browser). The application js file is definitely named app.js. Further, any attempt to modify something registered in Application Manager throws 2 errors: - Error: The required parameters are invalid or missing. Error #1: Invalid configuration for the parameter "python"
- Error: Your application is incomplete or invalid.
0 -
Just for other people, I brought someone in who knows a lot more than me. They said: The cPanel app manager also doesn't handle starting/stopping apps (I'm not even really sure what it does honestly, other than generate an Apache config). I set up service management through systemctl: systemctl start|stop|restart etherpad 0
Please sign in to leave a comment.
Comments
5 comments