简体   繁体   中英

Deploying nodejs website on host server

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

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 .htaccess and in my case it did work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM