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.
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/con.d/. You will be looking for a
VirtualHost configuration for example.com.
Mine looked like this:
<VirtualHost 18.104.22.168:80> ServerName example.com ServerAlias www.example.com DocumentRoot /home/example/public_html/example.com ServerAdmin firstname.lastname@example.org </VirtualHost>
Once you have found your
VirtualHost configuration you can duplicate it and change it to
blog.example.com like this:
<VirtualHost 22.214.171.124:80> ServerName blog.example.com ProxyPreserveHost on ProxyPass / http://localhost:2368/ </VirtualHost>
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
service httpd restart