Deploy Node.js Apps To Shared Hosting

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • 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/iva...
    Twitter: / ivan_doric
    Instagram: / watchlearntuts
    Facebook: / watchlearntutorials

Komentáře • 99

  • @WatchandLearnTutorials
    @WatchandLearnTutorials  Před 2 lety +1

    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

  • @Skwlx
    @Skwlx Před 4 lety +5

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

  • @alex-desroches
    @alex-desroches Před 4 lety +4

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

  • @karthipalani7373
    @karthipalani7373 Před 3 lety +1

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety +1

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

  • @aleksandermirowsky7988
    @aleksandermirowsky7988 Před 4 lety +2

    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!

  • @ledeadeniyi
    @ledeadeniyi Před 4 lety +4

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

  • @genxindia1154
    @genxindia1154 Před 4 lety +2

    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  Před 4 lety +2

      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 Před 4 lety +1

      @@WatchandLearnTutorials Thanks I will keep that in mind

  • @DanielScottFilms
    @DanielScottFilms Před 2 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 2 lety

      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 Před 2 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 2 lety

      @@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
    @nickxipakis2380 Před 4 lety +4

    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

  • @Zmiize94
    @Zmiize94 Před 4 lety +2

    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  Před 4 lety

      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: czcams.com/video/IktnuT9UgbM/video.html

    • @teras8303
      @teras8303 Před 3 lety

      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 Před 3 lety

      @@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.

  • @vanmartyr
    @vanmartyr Před 3 lety +1

    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  Před 3 lety

      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 Před 3 lety

      @@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  Před 3 lety +1

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

  • @sameeraperera7912
    @sameeraperera7912 Před 4 lety +1

    thank you.....

  • @_boza
    @_boza Před rokem

    Do you have a video for deploying FE part?

  • @jhonatansantofimio3764
    @jhonatansantofimio3764 Před 2 lety +1

    npm install
    -bash: npm: command not found

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 2 lety

      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.

  • @nimeshthakor2546
    @nimeshthakor2546 Před 4 lety +1

    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  Před 4 lety

      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: czcams.com/video/IktnuT9UgbM/video.html

  •  Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

      I think I did that in the video.

    •  Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

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

  • @rajeshmondal8392
    @rajeshmondal8392 Před 2 lety

    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  Před 2 lety

      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.

  • @stephenrogers5458
    @stephenrogers5458 Před 4 lety

    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  Před 4 lety

      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: czcams.com/video/IktnuT9UgbM/video.html

  • @mykola.kushka
    @mykola.kushka Před 2 lety

    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  Před 2 lety +1

      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.

  • @kaveshriskmanagment5804

    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  Před 3 lety +1

      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.

  • @doyouknow1948
    @doyouknow1948 Před 4 lety

    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  Před 4 lety +1

      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.

  • @sgares6741
    @sgares6741 Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

      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.

  • @lamargtv2572
    @lamargtv2572 Před 3 lety

    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  Před 3 lety

      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.

  • @tebarei
    @tebarei Před 3 lety +1

  • @isthatsahil
    @isthatsahil Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety +1

      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 Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

      @@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.

  • @teras8303
    @teras8303 Před 3 lety

    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  Před 3 lety

      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.

  • @ramone09
    @ramone09 Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety +1

      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.

  • @case_tips
    @case_tips Před 2 lety

    Hi how to solve npm not found issue?

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 2 lety

      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.

  • @aceracer5556
    @aceracer5556 Před 2 lety

    Hello! How to config nginx ssl?

  • @oritkozolin7821
    @oritkozolin7821 Před 4 lety

    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  Před 4 lety +1

      You can create a start file. And in fact I did that in this episode: czcams.com/video/IktnuT9UgbM/video.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 Před 4 lety

      @@WatchandLearnTutorials Thanks, just what i was missing!

  • @mmlnv2036
    @mmlnv2036 Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

      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.

  • @kirarevcrow
    @kirarevcrow Před 3 lety

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

      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.

  • @groovebird812
    @groovebird812 Před 3 lety

    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  Před 3 lety

      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 Před 3 lety

      @@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  Před 3 lety

      @@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 Před 3 lety

      ​@@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  Před 3 lety

      @@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.

  • @adrianfam8098
    @adrianfam8098 Před 2 lety

    I cant get it to work :(:(

  • @ashishmangla221
    @ashishmangla221 Před 4 lety

    how i can host next js project on cpanel

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 4 lety

      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: czcams.com/video/IktnuT9UgbM/video.html

  • @pinyin1
    @pinyin1 Před 4 lety +2

    How do you get access to that command interface

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 4 lety

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

    • @pinyin1
      @pinyin1 Před 4 lety

      @@WatchandLearnTutorials yes

  • @tebarei
    @tebarei Před 3 lety

    bro ¿how i can use SSL?

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety +1

      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 Před 3 lety

      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  Před 3 lety +1

      @@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.

  • @zaheerRock
    @zaheerRock Před 3 lety

    title not justify , its all about strapi crap!!

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 3 lety

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

  • @mbparvezme
    @mbparvezme Před 2 lety

    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  Před 2 lety +1

      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 Před 2 lety +1

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

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  Před 2 lety

      @@mbparvezme Nice 👍