How to Host Ghost on an Apache Subdomain


Ghost runs on top of Node.js instead of Apache or Nginx. If you already have a website running on Apache you will need to take a few extra steps in order to allow Node.js to run along side Apache. After this tutorial you will have your main domain (we will use the domain example.com) served by Apache and your Ghost blog on a subdomain (blog.example.com) served by Node.js.

To add blog.example.com to Apache we will need to modify an Apache config file. The configuration we are looking for is typically found in /etc/httpd/conf/httpd.conf or /etc/httpd/con.d/. You will be looking for a VirtualHost configuration for example.com.

Mine looked like this:

 <VirtualHost 192.163.214.135:80>
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot /home/example/public_html/example.com
     ServerAdmin webmaster@example.com
 </VirtualHost>
Once you have found your VirtualHost configuration you can duplicate it and change it to blog.example.com like this:
 <VirtualHost 192.163.214.135:80>
     ServerName blog.example.com
     ProxyPreserveHost on
     ProxyPass / http://localhost:2368/
 </VirtualHost>
This new VirtualHost section tells Apache to pass the request to http://localhost:2368 and we have Ghost listening on port 2368. Now restart Apache:
service apache2 restart

or

service httpd restart

You can access example.com and Apache will serve the request and blog.example.com will be served by Node.js which is your Ghost install.