Lately, many web developers have found it difficult to host applications built with a "NodeJS" server, especially users of shared hosting who rely on cPanel/DirectAdmin for their needs and do not have SSH access for server installations.
CloudLinux has released a new feature called NodeJS Selector, which allows cPanel/DirectAdmin users to run NodeJS programs.
Several NodeJS versions are available, from version 6, 8, 9, up to the latest (recommended).
Before we begin the installation, here’s what you need to prepare:
- cPanel/DirectAdmin Panel: Your shared hosting account.
- A provider that offers the NodeJS feature: Some providers now allow their customers to host NodeJS applications. If your provider does not offer this, unfortunately, this tutorial may not be for you.
Installation/Setup Steps:
- Log in to your panel (cPanel/DirectAdmin).
- Create a new NodeJS application by clicking the “Create Application” button.
- Select a NodeJS version; using the latest (Recommended) version is advisable.
Application mode: You can choose whether this is for development or production.
Application root: This is the folder where your NodeJS application will be stored, or the name of your project folder. For example: nodejs
Application URL: This is used to set the URL where the NodeJS app will be accessed. Here, I have the default option from my hosting domain name "chiqors.xyz". If I add "nodejs" as the URL name, the final URL to access the application will be "http://chiqors.xyz/nodejs".
Application startup file: This is the initial file that NodeJS will read. In this case, you can enter index.js.
Then, click the “Create” button.
Your NodeJS application has now been created and can be accessed at http://yourdomain.com/nodejs.
You can view the detailed information of the created App URL by clicking the "pencil" icon, which will bring up a display like this:
There is a message “Enter to the virtual environment”. This is intended for those who have SSH access to check the NodeJS server system, such as viewing the node/npm versions in use. However, I will not be covering that setup.Ensure the NodeJS application is running correctly. Test it by clicking the “Start” button (Make sure to save first).
If the status is started (meaning NodeJS is running), test the URL you created.
This means you have successfully run the NodeJS app you created.
Congratulations, you have successfully installed NodeJS on your shared hosting. It's also important to know what to do if you see the “Detected configuration files” message in the app details. Typically, after creating a new app, you need to upload your “package.json” file to your project folder.
Navigate to the URL/Folder you created and upload the “package.json” file you have prepared! Once you've done that, it will look like this:
Once you have uploaded the package.json
file, you can now access the command for “npm install”. Please use this feature according to your needs. You can also use this to import your existing NodeJS project folder for deployment to your hosting.
Hopefully, this guide will be useful for aspiring web developers who use JavaScript as a backend programming language. Thank you for reading, and don't forget to leave a like as a sign of your support! See you in the next tutorial :)
Top comments (2)
thanks infonya, kmrn2 nyari shared hosting susah nemu yg support node js.
btw utk deploy nodejs make docker di vps (ubuntu) ada tutorial yg rekomen utk dibaca/difollow?
Maaf, saya baru sempat baca sekarang. Kalau tutorial nodejs pakai docker sepertinya sudah banyak. Kalau rekomendasi, saya biasanya cari sendiri di google atau youtube.