Deploy a Node.js app on shared hosting via cPanel | Tutorial
Tutorial Hosting
Hello everyone and welcome to this tutorial so today what I’m going to be showing you is how you can deploy a node.js app to Shared hosting space via the cpanel interface so I’m going to be deploying my app to some shared hosting space I have with
This company posted with love so in case you don’t already have some space they do some pretty good deals starting at 490 per month and if you purchase over a longer time period it can be even cheaper so over three years it works out to 392 dollars
Per month at the time of this recording and the good thing is that in all of their packages all of their shared hosting packages node.js is supported on the server so I’ll post a link to this in the description below this video in case it’s something that interests you
So I’m already inside cpanel on my shared Hosting account the first thing I’m going to do is to create a new subdomain for my node app so if you go down to domains and then sub domains you can enter the new subdomain here ANC panel will do the rest so I’ll call this
New node app okay and then if I click away it’s telling me that the document root so the physical location of the files for the subdomain are going to be located in a folder called new no doubt dot open javascript.info so that’s going to be a
Folder that it creates in the root of my shared Hosting account so I’ll go ahead and click create here foreign that means automatically a folder will have been created in the root of my shared Hosting account so we’ll open up the file manager to see that see it’s here I didn’t create this
Before the tutorial this was created automatically when I created the new subdomain and as you can see it’s almost empty so what you want to do here is to upload the app files themselves minus the node modules folder so you could also upload the node modules folder but
If you have a package.json file in your app directory then those will be installed server side when we set up the node app so for now all I’m going to upload here is app and the package.json files so on the server side in cpanel here
I hit upload and I can just drag and drop those files okay so the amp files are now inside had the root folder for the new subdomain so we should be able to see those if I go to new node all right sorry you no doubt dot open JavaScript which is my main
Domain open javascript.info then we should see the files exist here but we haven’t started the app yet so to do that you go back into cpanel and the quickest way to find it is just buy a search here so you want to access setup no doubt under software and then click create application
Now the application URL is going to be the subdomain that you have created and the application group is going to be exactly the same as this this is actually different from the URL this is the physical location the root of your app on your shared Hosting account
So it saved it in a folder which is which has the same name as the URL so that can be a little bit confusing now the startup file for my app is called app.js so this is my app very simple it’s returning a H1 title in HTML format and I’m asking my
App to listen adaptively so to the port that the server decides to run the app on now back in cpanel if you want to set the port manually you can do that by adding an environment variable here so the name of it should be port and
Then we can set it to run on for example Port 3002 so it will actually work without this so I’m just going to leave this empty but if you do want to hard code the port that it runs on then you can do that down there now all you have
To do to start up the server is hit create here so after a few moments the app will be up and running so if I refresh the URL of the subdomain you see it’s 503 at the moment but that is because we haven’t installed the express dependency that
This app depends upon so we have to go back into cpanel here and I’m going to stop the app and this is where you install the dependencies so click here and that’s going to install all the dependencies listed in package.json so that’s why it’s important to include the
Package.json file and why you can get away without uploading the node modules folder okay now if we access this URL again and as you can see it’s sending back the expected result so the server is up and running and express has clearly been installed now finally if you have SSH
Access to your shared Hosting account then you can log in in the normal way and then if you run this command here this is going to allow you to work with your app via the command line just like you would locally in the terminal and that’s it so it’s pretty straightforward
And now you’re able to test your node app in a live environment so I hope you found this useful if you did please consider hitting the like button down below this video it helps us with the algorithm and others to find this video and if you’d like to see more content
Like this from us in the future don’t forget you can subscribe to the channel
๐ More tutorials like this: https://openjavascript.info โ๐ NEW: Earn a Professional Certificate in Web Development from Meta Inc. (Course links in map below) ๐ โก Looking for powerful, affordable web hosting? We use HostWithLove: https://bit.ly/3V2RM9Q โค๏ธ This tutorial shows you how to deploy a Node.js app to a shared hosting account that supports Node.js apps via cPanel. #nodejs #cpanel #sharedhosting #app #deploy #webdevelopment #tutorial ๐ Subscribe for more tutorials simply as follows: http://www.youtube.com/channel/UC26_rFZReLXNu8bULVARUXg?sub_confirmation=1 โกWeb Development Professional Certificates from Meta Inc. โก Front-End Developer Professional Certificate: https://imp.i384100.net/b3dMek Back-End Developer Professional Certificate: https://imp.i384100.net/gbYorg iOS Developer Professional Certificate: https://imp .i384100.net /Jr7qj2 Meta Android Developer Professional Certificate: https://imp.i384100.net/oeYnGo Meta Database Engineer Professional Certificate: https://imp.i384100.net/BX7KGB Website: https://openjavascript. info
#Deploy #Node.js #app #shared #hosting #cPanel #Tutorial
https://i.ytimg.com/vi/emDCYo5Rz0E/hqdefault.jpg