Hosting multiple websites on one server with Apache 2.4 (including Node) on Ubuntu 12.04

Categories Uncategorized
While I was setting up my VPS (Virtual Private Server) Ubuntu 12.04. I had a lot of difficulties with running my existing Node.js server with Apache 2.4.

I had multiple domains that I wanted to host on one server, one was a Node.js server and the other was Apache 2.4.

The solution took me a bit of some Googling and trial and error.

Go to /etc/apache2/sites-enabled/000-default.conf

To set up with node, we need to enable proxypass:

sudo a2enmod proxy
sudo a2enmod proxy-http

Edit it as such:

NameVirtualHost *

<VirtualHost *:80>
    ServerName myapachedomain.ca
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/mywebpage1
</VirtualHost>

<VirtualHost *:80>
    ServerName myapachesite2.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/mywebpage2
</VirtualHost>

### FOR NODE.JS SERVER
<VirtualHost *:80>
     ServerName mynodedomain.com
     ProxyPass / http://localhost:3000/
</VirtualHost>

Your node.js server should be running on localhost at port 3000