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:
Once you have found your
<VirtualHost 220.127.116.11:80> ServerName example.com ServerAlias www.example.com DocumentRoot /home/example/public_html/example.com ServerAdmin firstname.lastname@example.org </VirtualHost>
VirtualHostconfiguration you can duplicate it and change it to
<VirtualHost 18.104.22.168:80> ServerName blog.example.com ProxyPreserveHost on ProxyPass / http://localhost:2368/ </VirtualHost>
VirtualHostsection tells Apache to pass the request to
http://localhost:2368and we have Ghost listening on port 2368. Now restart Apache:
service apache2 restart
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.