How to Create a Node.JS Application (Legacy Method)
Posted by Tony B., Last modified by Tony B. on 14 September 2018 02:10 PM
This article advises you on how to create a node.js application using a cron jobs and php. This is no longer necessary you can do it from our own interface and there exists a guide at https://support.hawkhost.com/index.php?/Knowledgebase/Article/View/197/0/how-to-create-a-nodejs-application . However for users using this method it remains accessible for their reference.|
At Hawk Host it is possible to create persistent Node.JS applications utilizing several of our built in features. We will walk you through how to create a node.js hello world but the same can be applied to applications such as Ghost
1) You'll need to create a nodejs folder within your accounts home directory which can be completed by FTP/SFTP or throuhg the cPanel file manager. After this is created you will create an app.js file inside your nodejs folder with the following contents:
Replace 12345 with a randomly generated 5 digit number and record this as it'll be necessary later on.
2) You now need to create a PHP file which will be used to manage your application. Create a cron.php file with the following contents:
Change the 12345 to contain the port number you randomly generated previously.
3) You will now need to login to cPanel and open the cron jobs option
You will need to create a cron job with the following settings:
The cronjob command is
Replace username with your accounts username.
4) The final step is to make it possible for the web server to connect to your Node.JS application. Navigate to where you wish for your application to load from which in our case will be the public_html folder. Create a .htaccess file with the following contents:
Replace 12345 with your random port you generated and upon visiting the location your Node.JS application should now load.