Deploy Node.js Apps To Shared Hosting

In this episode we are going to deploy Strapi backend from Next.js and Strapi series to the shared #hosting.
Now we are going to take #Strapi backend that we have been building in Making Websites With Next.js And Strapi series, and we are going to publish it on a shared hosting with #cpanel. As you will see, depending on your hosting this may not be the most viable solution. But if nothing else it will be fun to try, and learn something new.
Also I'm going to show you how to redirect port 8080 of your server so that the visitors to your website don't have to input a port to access your website.
Code used in this video
bit.ly/367qRSg
You can support my work on Patreon
/ watchlearn
Follow me on Social Media
Github: github.com/ivandoric
Twitter: / ivan_doric
Instagram: / watchlearntuts
Facebook: / watchlearntutorials

Пікірлер: 99

  • @WatchandLearnTutorials
    @WatchandLearnTutorials2 жыл бұрын

    PLEASE READ BEFORE COMMENTING: so this video is here just to show you that you could IN THEORY deploy Node apps to shared hosting. HOWEVER, you should not be doing this for any type of production website, because it will probably not work well and even if you use something like PM2 it will just stop working after a few days. If you wanna deploy Node apps better use something like Digital Ocean or AWS. You can use this link to get $100 credit on Digital Ocean over 60 days so you can play around with it: m.do.co/c/808fb4bb0039

  • @aleksandermirowsky7988
    @aleksandermirowsky79883 жыл бұрын

    Just discovered your channel a few days ago and let me just say that your content is legendary. Amazing stuff all around. Good job, mate. Cheers!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Welcome aboard and thanks for watching ;) Tell your friends :)

  • @Skwlx
    @Skwlx3 жыл бұрын

    Thank you very much! I was searching for a video like this for days!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    You are welcome 😃Thanks for watching.

  • @ledeadeniyi
    @ledeadeniyi4 жыл бұрын

    Thank you for this! I'm also looking forward to Easy Deployment with Git and CPanel. Especially how to handle automatic deployments

  • @alex-desroches
    @alex-desroches3 жыл бұрын

    Thanks man I've never gotten so far into deploying as with you

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Glad I could help ;) , thanks for watching.

  • @karthipalani7373
    @karthipalani73733 жыл бұрын

    Without this I ain't able to deploy project to live thanks dude

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Glad I could help 😀 , but as I said in the video this setup is not ideal. So keep that in mind.

  • @genxindia1154
    @genxindia11544 жыл бұрын

    Thanks man I wish have found you earlier, I wanted to deploy ghost on my Cpanel but couldnt but now tis already too late I am on wordpress now but I have saved this video in case I need this in future ever.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    4 жыл бұрын

    But remember, as I've said in this video shared hosting with cPanel is not a good solution. Better stick to WP for shared hsoting, and host node apps on something like Digital Ocean.

  • @genxindia1154

    @genxindia1154

    4 жыл бұрын

    @@WatchandLearnTutorials Thanks I will keep that in mind

  • @DanielScottFilms
    @DanielScottFilms2 жыл бұрын

    Great tips. I'll be deploying a Strapi app soon!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Don't do it this way please 😀 as I said in the video this is not good for production websites. Better use something like Digital Ocean, AWS, etc. This is only going to cause you headaches.

  • @DanielScottFilms

    @DanielScottFilms

    2 жыл бұрын

    @@WatchandLearnTutorials If I'm on Centos, would it be less of a headache if I installed with Pm2?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@DanielScottFilms You should use PM2 for sure, however on my shared hosting even after using PM2 the site would still go offline every 2,3 days, and I would have to restart it manually. Of course on Digital Ocean this works great.

  • @nickxipakis2380
    @nickxipakis23804 жыл бұрын

    Unfortunately my host server not support node js.. at last i use heroku to deploy..i want thank you!! and keep on to help people to solve issues

  • @sgares6741
    @sgares67412 жыл бұрын

    Thanks man. How do I connect my strapi app with the MySQL that my hosting provides though ? (instead of using data.db)

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Don't use this for production, shared hosting is not good for this type of setup, better use something like Digital Ocean or AWS. I'm not even sure how you can connect to MySQL on shared hosting or even if it's possible.

  • @sameeraperera7912
    @sameeraperera79124 жыл бұрын

    thank you.....

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    4 жыл бұрын

    You are welcome sir ;)

  • @teras8303
    @teras83032 жыл бұрын

    Hello Ivan , thanks for the video. Unfortunately I tried deploying my strapi proyect to Namecheap shared hosting servers using the create nodejs application method and the CLI but wasnt able to get the development server to work. For both cases I had similar issues with the sharp module. Im getting the following error: Cannot find module '../build/Release/sharp.node' ,im using node v10.24.1 and 6.14.12. Do you know if I could try using an older strapi version? Thanks

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Probably not. You need to have at least version 12 of Node.js to be able to run Strapi. So if your hosting does not support that, then you are out of luck, sorry. And also as I mentioned in the video this is just to show that this can be done on shared hosting, but IMO you should not deploy production Node.js apps to shared hosting. It's very unstable, you should use something like Digital Ocean or AWS or something similar.

  • @doyouknow1948
    @doyouknow19483 жыл бұрын

    Hi... Thank You...can you explain how angular and nodejs (express back end) app deploy in shared hosing..using CPanel option 'setup Node.js app' i tries but doesnt work...

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    I never used Angular, so can't really help you there. But as I've said in this video this setup is not optimal for node apps, you really should be using something like Digital Ocean.

  • @mykola.kushka
    @mykola.kushka2 жыл бұрын

    It looks I am able to run on my shared hosting only in development mode (blue label "Development" - on Strapi page). And I am not able to run in Production mode (green label). Not sure if there any difference for Strapi?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Production mode is better performant. Since you are using this on shared hosting the problem probably is that you don't have enough resources to make a production build. That's why I say in the video that this is not production ready, and you would be better off using something like AWS, Digital Ocean etc.

  • @vanmartyr
    @vanmartyr2 жыл бұрын

    Hi, is it possible for me to host strapi and also a front end (angular) that uses data from strapi on the same domain?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    It is. But don't do it. At least not on shared hosting, as I've said in this video this is not good solution for production apps. Better use something like Digital Ocean, AWS, etc.

  • @vanmartyr

    @vanmartyr

    2 жыл бұрын

    @@WatchandLearnTutorials thanks, yeah I was looking at digital Ocean. I'm just moving away from using monolithic CMS like umbraco, and I'm surprised by cost and effort it seems to take to host headless solutions

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@vanmartyr Yup. Sometimes I ask myself if it's even worth it 😀

  • @nimeshthakor2546
    @nimeshthakor25463 жыл бұрын

    hey i have some problem i have upload my code to server and thats perfectly run fine but after 2 or 3 days the server automatically stopped and i have to restart it again :( any solution for this?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Yes, don't deploy your apps on shared hosting, as I said in the video there are still problems with that unfortunately. The same thing happened to, even when using PM2, so that sucks. Better use something like Digital Ocean... also I have a video about that that you can check out: kzread.info/dash/bejne/e5-o0NeNabjNkrA.html

  • @rajeshmondal8392
    @rajeshmondal83922 жыл бұрын

    Hello sir, I have a node js backend and react frontend web application with lerna monorepo. How can I deploy it in one subdomain in cpanel?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    No idea. Sorry. Also, do not do this on shared hosting (if it's even possible) because you're gonna have a bad time. Shard hosting is not made for something like this.

  • @Zmiize94
    @Zmiize943 жыл бұрын

    I followed your guide as much as I could being that shared hosting sites are different across countries. For instance, the Cpanel I'm currently using doesn't have NodeJS runner, instead I installed node on the terminal, but it uses jailshell. The issue I had was that everytime i tried installing the node modules for strapi, the sharp library installation would fail as some of its modules like "libvips" would fail to compile in jailshell. So I cannot complete this process thoughly as I'm limited by the shell, other than that I guess using this sort of shared hosting works with nodeJS as long the npm modules don't need to compile on the target system. If you know a way around that, let me know.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    You could try just copying node_modules from your local machine, but that would suck very much. As I've said in the video Node apps should not be deployed on shared hosting for the time being. I've even had problems in this video. It's much better to use something like digital ocean or AWS. I have a video about that, you can check that out if you like: kzread.info/dash/bejne/e5-o0NeNabjNkrA.html

  • @teras8303

    @teras8303

    2 жыл бұрын

    Hi, im facing almost the exact same issue with the sharp module and the libvips that is required by strapi-plugin-upload. Did you manage to solve this issue?

  • @Zmiize94

    @Zmiize94

    2 жыл бұрын

    @@teras8303 No, the shared hosting you may be using won't allow for some node packages to compile in jailshell. Try Directus 8 or another type of cms based on php instead.

  • @tebarei
    @tebarei3 жыл бұрын

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    No problem. Thanks for watching 😃

  • @stephenrogers5458
    @stephenrogers54583 жыл бұрын

    This is a great tutorial. I am following it to work with A2Hosting, but my situation requires deploying a Vue app with Express / MySQL back end (the Node part). On my dev environment I am able to serve the Vue app in production (built) mode by having Express serve Vue as well as the api. I have not yet succeeded with this on A2Hosting. I am following the advice from this tutorial and creating a subdomain. If you have advice on this, I would appreciate it!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    As I've said in the video this solution is not optimal, and it should not be used for critical projects, only for personal projects. Because even if you are able to make it work, chances are that your app would stop working after a few days and you would have to manually restart it. So that sucks. Better use something like Digital Ocean. I have a video about that also: kzread.info/dash/bejne/e5-o0NeNabjNkrA.html

  • @kirarevcrow
    @kirarevcrow3 жыл бұрын

    Can we host strapi and React on the same share hosting? like cPanel?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Technically yes. But as I said in the video this setup is not production ready. At least not on my hosting, you may have better luck with your hosting however. But I still think that something like AWS, Digital Ocean etc. is much better option.

  • @oritkozolin7821
    @oritkozolin78213 жыл бұрын

    But how do you deploy the NextJS part to shared hosting with cPanel ? The main problem is that the build of NextJS does not include any startup file that can be used in the 'Node' app settings in cPanel. How do you go around that?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    You can create a start file. And in fact I did that in this episode: kzread.info/dash/bejne/e5-o0NeNabjNkrA.html where we deployed our app on Digital Ocean. I think you could use that start file for cPanel also: github.com/ivandoric/Making-Websites-With-Next.js-And-Strapi/blob/master/digital-ocean/start-files/NextApp/start.js

  • @oritkozolin7821

    @oritkozolin7821

    3 жыл бұрын

    @@WatchandLearnTutorials Thanks, just what i was missing!

  • @ramone09
    @ramone093 жыл бұрын

    my cPanel does not have "Setup Nodejs App" tool. How can I install it?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    You probably can't. If it's not there, then your hosting provider probably doesn't want you to have it. You can try asking them to install it for you, but I wouldn't get your hopes up. However as I said in this video and in the comments, this is not optimal solution for Node apps, much better to use Digital Ocean, AWS or similar services.

  • @_boza
    @_boza Жыл бұрын

    Do you have a video for deploying FE part?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    Жыл бұрын

    No I don't.

  • @lamargtv2572
    @lamargtv25723 жыл бұрын

    Error /home/dgpmallc/nodevenv/nodejsapp/12/bin/npm: fork: Cannot allocate memory I get this error when i run npm install. Can anyone tell me why?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    I think I had the same problem in this video. That's why I suggest that you build your site locally. And the error is just what it says, there is not enough memory to build the site. And also as I said in the video this setup is just to show that it can be done, but if you wanna have a production ready app that people are gonna use, don't use shared hosting, because there are problems with it as you can see. Better try AWS or Digital Ocean or something similar.

  • @aceracer5556
    @aceracer55562 жыл бұрын

    Hello! How to config nginx ssl?

  • @isthatsahil
    @isthatsahil3 жыл бұрын

    Getting 403 forbidden error when creating a sub-domain on root directory instead of public_html folder.. Can someone please help ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Why don't you create sub domain in public_html? Maybe your hosting provider doesn't allow for sites to be outside public_html. Also note that this video is just to show that something like this is possible, but honestly, you shouldn't put your production node.js app on shared hosting. Better use something like Digital Ocean.

  • @isthatsahil

    @isthatsahil

    3 жыл бұрын

    @@WatchandLearnTutorials thanks for the help.. also if you can explain what’s the difference between shared hosting like goDaddy and digitalOcean?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    @@isthatsahil Read first two answers on here: www.quora.com/How-is-a-DigitalOcean-droplet-different-than-a-shared-host-security-wise and just remember, if using DO you mostly have to setup everything yourself, but you have much more control over everything, because technically you get your OWN server , as opposed to shared hosting where you... well, SHARE you hosting with other people.

  • @yashinnews
    @yashinnews2 жыл бұрын

    Hi how to solve npm not found issue?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    You probably can't, if Node/NPM is not installed on your shared hosting there is little chance that you can install it yourself. You can try contacting your hosting company to see if they would install it for you, but even if they do this would be a waste of time. Please read pinned comment for more info.

  • @mmlnv2036
    @mmlnv20362 жыл бұрын

    Npm doesn't get recognized as a command , any ideas ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    You don't have Node and NPM installed on the server probably. And since you are using shared hosting I doubt that you can install it yourself, you would probably need to contact your hosting provider.

  • @ashishmangla221
    @ashishmangla2214 жыл бұрын

    how i can host next js project on cpanel

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    4 жыл бұрын

    Try this: www.a2hosting.com/kb/cpanel/cpanel-software/create-application-with-nodejs-selector as I've said, cPanel/shared hosting is not ideal solution for deploying NodeJS apps. Better use something like Digital Ocean: kzread.info/dash/bejne/e5-o0NeNabjNkrA.html

  • @kaveshriskmanagment5804
    @kaveshriskmanagment58043 жыл бұрын

    First of all thanks a lot for making this video, it help me a lot but there is an issue when I ssh to server and then go to that directory where my application live, and write npm install I get this error "-bash: npm: command not found" although my cpanel is supporting node js app, if you could help me to solve this problem it would be appreciated.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Well seems to me that your server doesn't have Node.js installed or npm. However Node usually comes with npm out of the box so I would say that your server doesn't have Node.js installed at all, or is using some super old version. You have to check that with your hosting provider.

  • @jhonatansantofimio3764
    @jhonatansantofimio37642 жыл бұрын

    npm install -bash: npm: command not found

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    You don't have npm installed on your host, that probably means that you don't have Node.js installed. Try contacting your hosting to see if they have servers with Node. And also please read the pinned comment before that and then decide do you even wanna try this.

  • @groovebird812
    @groovebird8123 жыл бұрын

    How do you connect the subdomain with strapi? In your video strapi is running on localhost but i think your subdomain runs under a public ip and not localhost

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Strapi and other Node.js apps are always going to run on localhost. But I explain in this video how to run it on subdomain. What is the problem you are running into?

  • @groovebird812

    @groovebird812

    2 жыл бұрын

    @@WatchandLearnTutorials i want to run strapi on a production server with a domain and not local. if i enter my domain in the browser nothing happens. I can't see the strapi backend, because it runs on localhost. Localhost is not accessible from outside. How did you solve this? What are you doing that you can enter your subdomain and the strapi backend is working.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@groovebird812 It is actually shown in the video. And as I've said Node.js apps always run on localhost, but localhost is not just on your machine, if you run it on the server it's going to run on that servers localhost on port 1337. And I'm actually setting my subdomain in the video around 2:30 mark. So I still don't see what problem you are running into. Also keep in mind (and I talk about this in the video) that you should NOT put your production app on shared hosting, this video was just to show that it can be done, but it doesn't mean you should do it, because it won't work well. It would be much better to use something like AWS, Digital Ocean or any of the other similar services.

  • @groovebird812

    @groovebird812

    2 жыл бұрын

    ​@@WatchandLearnTutorials it was my fault, sorry. I had to enable port 1337 on my testserver. I didn't know that the domain on port 1337 will internally be mapped to show contents from localhost:1337. Is this because of the port? I always want to understand whats going on but with this i don't understand it completly :-) The htaccess i will try later :-)

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@groovebird812 You did good, sometimes ports are "locked" and if your site is using unlocked port it will not work. Usually node apps run on a specific port so you have to enable those, or set it to run on port 80 or 8080 which is in most cases default port for serving web sites, but most times you can't set that on shared hosting because port 80 is reserved for public_html directory.

  • 3 жыл бұрын

    for your case, it will be better to build a project locally and then send it to host over FTP

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    I think I did that in the video.

  • 3 жыл бұрын

    @@WatchandLearnTutorials you uploaded to shared host installed npm packages and then build it on the shared host

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    @ No I didn't 😀 ... I tried to build it, but that failed (not enough memory). Then I did what you suggested.

  • @tebarei
    @tebarei3 жыл бұрын

    bro ¿how i can use SSL?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    You have to install SSL certificate for your domain. Try finding out if your hosting supports Let's Encrypt (letsencrypt.org/) so that you don't have to pay for the SSL certificate. This is not really my strong suit so that is the most info I can offer you.

  • @tebarei

    @tebarei

    3 жыл бұрын

    can you make a video tutorial to make it work in ssl? my cpanel gives me SSL and I can't find how to make it work 😢😢

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    @@tebarei You have to talk to your hosting provider about that. It tends to be different from provider to provider, so I can't make a tutorial for most people, only for the provider I use.

  • @adrianfam8098
    @adrianfam8098 Жыл бұрын

    I cant get it to work :(:(

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    Жыл бұрын

    Please read the pinned comment.

  • @pinyinxingming1821
    @pinyinxingming18214 жыл бұрын

    How do you get access to that command interface

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    4 жыл бұрын

    You mean cPanel? Your hosting provides that, if they support cPanel. Most of hosting companies do.

  • @pinyinxingming1821

    @pinyinxingming1821

    3 жыл бұрын

    @@WatchandLearnTutorials yes

  • @zaheerRock
    @zaheerRock3 жыл бұрын

    title not justify , its all about strapi crap!!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    3 жыл бұрын

    Strapi is a Node.js App. I don't see the problem. Similar steps should be taken for any other Node app.

  • @mbparvezme
    @mbparvezme2 жыл бұрын

    Hello Ivan. Thank you for this awesome video. This is the first time I'm working with Strapi on the cPanel server. Your "npm install" shows no error. But in my case "npm install" script had the following error. Could you please help me with this? ... 40101 warn @strapi/helper-plugin@4.0.3 requires a peer of qs@6.10.1 but none is installed. You must install peer dependencies yourself. 40102 warn react-virtualized@9.22.3 requires a peer of react@^15.3.0 || ^16.0.0-alpha but none is installed. You must install peer dependencies yourself. 40103 warn react-virtualized@9.22.3 requires a peer of react-dom@^15.3.0 || ^16.0.0-alpha but none is installed. You must install peer dependencies yourself. ...

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Don't use this for production. You should not deploy node apps to shared hosting because it won't work as expected. Better use Digital Ocean, AWS or similar. As for the errors it says that you need to install peer dependencies yourself. So try doing that: npm install qs@6.10.1 react@^15.3.0 react-dom@^15.3.0 ...

  • @mbparvezme

    @mbparvezme

    2 жыл бұрын

    @@WatchandLearnTutorials Thank you for your reply. Already started with AWS.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@mbparvezme Nice 👍