There are many ways you can do this, so there’s no way I can put an answer by teaching step here.
Option 1
You can also use hostgator but it needs to be a VPS package. See Nodejs at the hostgator, you can open a ticket that they do the installation for you.
Option 2
You also have options that make deploying easier by simply using git as the Heroku and Netlify. These last two contain several tutorials on how to do it and it’s very simple, just configure the git part and modify some options in package.json that it does everything automatically.
Option 3
But being treated more manual. You can use the PM2 for persistence of your application, if you have an error or something like it does not break and the server falls.
The Nodejs by itself would already act as a server... In the same way that runs local, you would only have to leave this external ip.
Option 4
Other option is you put the rolling site Node on the server with the PM2
and use a . htaccess to redirect to that local address. How you handle PHP should be used to .htaccess
. What you can do is create a rewrite on it, for example
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]
Replace the XXXXX with your port that the Node server is running. That the redirect would work. Remember to use PM2 so that when an exception occurs or something breaks the application, the server does not fall.
Cool! But for example, I have apache installed on my server where I run some systems in PHP. And it runs on top of an address (example.net.br). How do I put my API running on: api.exemplo.net.br ?
– Andre Junior
You need to set up a DNS pointing to your server ip running in nodejs
– Anderson Henrique