Running node.js along side a website using Apache

Twitter Facebook Pinterest Google+ Stumbleupon LinkedIn

Node.js doesn’t need apache to run but if you’re running a node.js script on the same server along side the rest of your website we can set this up with some basic apache config.

Node.js will probably be running on it’s own port so make note of what that is.

Take a look at your apache http.d config file to make sure the following two lines aren’t commented out. These two lines will enable two apache modules “proxy” and “proxy_http”

LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

The next step is to edit the virual host file and add the ProxyPass rule.

DocumentRoot “/var/www/”
ProxyPass /node

This will make load up the nodejs script running on port 8080.

By setting up a node script like this we can run a nodejs script along side a PHP website on the same server. Perfect for small projects.

Posted by Adi on November 25, 2016

Twitter Facebook Pinterest Google+ Stumbleupon LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *