using nodejs on shared hosting

Here is the trick which I use to run nodejs in my shared hosting server.
you must have shell access to set-up node-js in your hosting.

This is not a detailed guide.

1. Login into the server.
2. Upload nodejs binary into the server. Or use wget or curl to download the nodejs binary.
3. Now add bin path of the nodejs to the environment (i.e your .profile file)
4. update the environment variable by running
      source .profile
5. check if node is available by typing node 

   Now run your nodejs app. 

6. Open the .htaccess file in your in public html folder
7. Enter the following in the .htaccess file.

     RewriteEngine On
     RewriteRule ^$ [P,L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$$1 [P,L] 
     DirectoryIndex disabled is your nodejs application port.

Now all your request will be routed to nodejs running.


Post a Comment

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !