using nodejs on shared hosting

sapan
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 ^$ http://127.0.0.1:3000/ [P,L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L] 
     DirectoryIndex disabled


http://127.0.0.1:3000/ is your nodejs application port.

Now all your request will be routed to nodejs running.



Tags

Post a Comment

0Comments
Post a Comment (0)

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

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