How to Install and use Node.js on Smarthost Server Smarthost SSH access is required to use Node.js. Access can be enabled via the Customer Area https://www.smarthost.eu/panel/login or all hosting accounts, except for the base-micro package. Click the magnifying glass icon next to the service, and then the Enable SSH button. The package cannot be in the trial version (must be paid for).
Installation of Nodejs
1. We connect to SSH using the port specified in the client panel. We can use Putty for this purpose.
2. We enter
cd
and press enter
3. We select the Nodejs version we are interested in from the https://nodejs.org/dist repository. For the purposes of this guide, nodejs v21 will be used.
4. Now we need to download the selected version of nodejs through the terminal using the command:
Instead of PORT, enter a number from the range 49152 to 65534. If the port is occupied by another Client, we select another one until the application will work on it. You should also remember to set the same port in the Node.js application.
All you have to do now is enter our domain and you will see a page served by Node.js.
Redirect to secure https connection with SSL cPanel
We can also redirect traffic with the server to a secure https connection. Attention! We run the Node.js server as http, not https. The https connection is provided by our Apache server. The cPanel certificate is generated automatically after adding a domain via Additional Domains in cPanel, so you don’t have to worry about installing and configuring an SSL certificate.
Use the following contents of the .htaccess file to force redirection (changing PORT to a number in the range given above):
For the ws:// protocol to work properly, you need to create rules in .htaccess, for example, for the socket.io library, add the following lines under the “RewriteEngine On” line (changing the PORT to the previously selected number):