Namecheap Shared Hosting & Multiple Node JS Apps - node.js

Is it possible to have multiple Node JS apps run on a single shared hosting plan running cPanel?
I have successfully installed the specific version of Node JS to my cPanel account using the following reference:
http://vinyll.scopyleft.fr/installing-a-custom-version-of-node-on-a-shared-hosting/
Now I just need to take my existing Node JS apps and get them running. I found the following helpful article on this so far:
https://www.ionicrun.com/running-a-node-js-application-on-shared-hosting/
I believe I can make sense of the instructions from the above link. However, the problem becomes how can I run multiple Node JS apps in one cPanel account?

Run your app in different port. Check for free ports and user any of them.
I usually use ports from 3000 to 4000. But, make sure your port is free.

Related

What is the recommended way to run a react app and a node js backend in the same container using cloud run

I would like to containerize a react app and node js backend API, that's currently running on a GCE VM. The majority of the information that's available online leads me to believe that I need to deploy them as separate containers to Cloud Run. However as Martin points out in the video - https://www.youtube.com/watch?v=WHH7eQLbG_s - Simplify your web apps on Google Cloud Run, that one could you use Cloud Run itself.
Is this possible and if so, is there any info. available online relating to this
Cloud Run can export only one port. Therefore, if you want to expose 2 different things (i.e. the frontend and the backend), you need to have a unique entrypoint.
You can wrap your static pages in your NodeJS backend server, or package, in your container, a NGINX server that will route to the react app the request to the static content, and to the nodeJS backend, the backend request.
About the Martin's video, you can also read my comments. It's better to deploy 2 different stuffs and to put a Load Balancer in front of both (similar to your NGINX in fact, but decoupled and therefore more scalable and easier to update). I personally recommend App Engine Standard for the static content (because serving that content is processing free, and the cheapest!), and cloud run for the backend.

Can we use Apache Server for server side rendering of angular web apps or we have to stick with NodeJs

Currently I am running NodeJs server as background process in the host machine to achieve sender side rendering for my angular app.
On Linux for e.g. npm rum server & (ampersand is to put process in background)
But I am looking for solution like Apache Server that manages it start/stop with host reboot.
I think the best way for you to acheive what you're looking for is to use a management solution like PM2 or Forvever. These will pretty easily manage your solution in the background for you.
Rather than apache/nginx managing start stop of your node application, you may create service to run your node application. It will run without any manual intervention.
Start your Node app on some other port than 80, as your main web server might be running on that port.
Create a service file in /etc/init to start your Node app
Configure apache/nginx with reverse proxy to the node applicaiton
Start both of the services: 'service start nodeapp.conf' and 'service start apache2'
This would make your life for handling these services pretty easy.
Yes. You should be able to.
Start by creating a proper deployment directory - https://angular.io/guide/deployment
Then copy/ftp/whatever to the web server.
The tricky part is in your route controllers, etc. and getting all of the paths right if you end up deploying into a different directory than what you developed for.
You need to use Apache/Ngnix with NodeJS using proxy.
Look into this link, if this helps:
https://blog.daudr.me/painless-angular-ssr/

Deploy a MEAN stack application to an existing server

I have a Ubuntu Server on DigitalOcean which hosts a website, and a Windows Server on AWS which hosts another website.
I just built a mean.js stack app on my MAC, and I plan to deploy it to production.
It seems that most of the existing threads discuss about using a new dedicated server. For example, this thread is about deploying on a new AWS EC2 instance; this video is about deploying on a new Windows Azure server; this is to create a new droplet in DigitalOcean.
My question is, is it possible to use an existing server (which hosts other websites), rather than creating a new server? If yes, will there be any difference in terms of performance?
My question is, is it possible to use an existing server (which hosts other websites), rather than creating a new server?
Yes. Both Windows and Ubuntu allows you to deploy multiple applications on same instance.
For Ubuntu you can read this post which will help you server multiple apps.
In this example used Nginx, but you can follow to this example and use it without any server like Apache or Nginx. If you need subdomains I would suggest to use Apache virtual hosts with reverse proxy module and pm2
For Windows and its IIS I would suggest to use iisnode, in google you can find a lot of articles how to configure it.
will there be any difference in terms of performance?
It is depended on your applications, if you are already serving applications which handles huge traffic and need CPU and memory, I would not suggest you to use multiple apps on same instance, but if you are going to use simple web apps, you can easily use same instance.
Hope this answer will help you!

digital ocean ubuntu 14.04 hosting multiple node JS apps

I am a beginner at node JS and web hosting in general. After playing around with the server, I have a node JS app running at my domain and it is using the port 3000. Is there a way of running multiple node JS apps in my ubuntu server 14.04 like this:
mydomain.com/nodejsapp1
mydomain.com/nodejsapp2
Right now I am only running a single app on the domain. This was done by using nginx. Is there any way I could run multiple node JS apps in a single domain like the example I gave above.
Yes, run those application the same way you run the first one, but specify other ports for them (i.e. 3001, 3002, etc.). Configure your nginx accordingly (same configuration like for the first application, but point it to your other applications on ports 3001, 3002, etc.).
And, I found this documentation on Digital Ocean website, describing exactly what you want to do: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04 the way I suggested. Just follow the steps from their tutorial.

How can I use my host, a regular dream host acct as a node server?

I've tried some methods online using ssh but can't figure it out. why is it so difficult to install when it's basically just Javascript?
A regular Dreamhost account will not allow a long running process which a node server is. You will need a VPS account.
Also, the node application and V8 engine inside it is not just javascript. It's an actual native application. Your scripts are "just javascript", but the infrastructure that makes the node server run is native code.
In 2015, Dreamhost started to support the deployment of nodejs (as well as ruby, python) applications through the Passenger domain option. For more information on Passenger, check Node.js with Passenger tutorial.
Unfortunately, this is available only on VPS running Unbuntu.
Note that on the Dreamhost wiki, under Nodejs, they write
DreamHost does not support node.js on shared web servers, as the security setup on DreamHost shared servers is incompatible with compiling or running node.js. If you try to compile node.js on one of the shared web servers, your user will automatically be banned through grsec (taking down all the php websites that run under that user) and the server will have to be rebooted before your user can be unbanned. If you do it one more time, you will be forced to move to a VPS.

Resources