Deploying nodejs website on host server

1.4k views Asked by At

I have developed a nodejs based website. It is working perfectly on my local PC, Heroku & Now server as well. Recently I purchased a hosting server from FastComet. Then simply uploaded my nodejs files VIA FileZilla to public_html folder. Then I login into the server VIA putty and installed the dependencies using "npm install". The server is cloudlinux OS based. Then I tried to run my nodejs server using "npm start", but I cannot see my website running in my website, just showing my files in the server. Can you please tell me how can I configure my nodejs in this server ? Should I change the port(3000) to my hosting server port(17177) ? I am new to hosting configuration. Any guidance would be helpful

1

There are 1 answers

3
Martiuh On

I hope by now you have solved this out, the team of FastComet did a good job helping me on setting up my node app, you just need to add these lines to the .htaccess file

RewriteEngine on
RewriteRule ^(.*)$ http://127.0.0.1:8000/$1 [P] #Change 8000 for your custom port

After doing that I was able to running node.js, but after that an unexpected bug appeared. I wasn't able to access '/' in an express app, that was because Apache was looking for index.html.var as the DirectoryIndex if you are having this bug, you just need to add

DirectoryIndex disabled

to the .htaccessand in my case it did work