using Ghost with Apache on Ubuntu Server
Ghost is built on top of Node.js, which has built in HTTP server — meaning that people who only run Ghost on their server don't need to bother with Apache. I am not such a person. Rather, I host several web-based applications from the same machine, and use Apache to direct my traffic.
NOTE: I am beginning to suspect this exposes me to some vulnerability and latency issues that could be avoided by swithcing to nginx, but for the moment I'm going to stick to what know.
Anyway... without further ado, here are the steps I used to install Ghost on Ubuntu 12.04.3 Server with Apache:
Most people reading this article probably already has Apache installed, and is merely need an easy configuration example. In the case you don't (and for the sake of excessive detail), here's how to install Apache:
sudo apt-get install apache2
To get Apache to play well with Ghost, you'll also need to install and enable modules:
sudo apt-get install libapache2-mod-wsgi a2enmod proxy proxy_http service apache2 restart
Asking Apache to Listen:
With Apache and mod_wsgi installaed, the next step is to ask Apache to listen to incoming traffic. Again, this is a step you've probably already taken at some point if you need Apache to direct traffic to Ghost. And if you've done it once — you're done (no need to double the entry)!
So again, to be explicit:
Navigate to you Apache directory —
cd /etc/apache2/ — and edit either your
httpd.conf or your
ports.conf file (your choice!) to listen on port 80:
...then add the line:
save and exit.
NOTE: Unless you've specified otherwise, the internet traffic coming from your URL domain will be on port 80.
Your choice of site management:
Now all we need to do is tell Apache what to do with incomming traffic. We configure bit of the puzzle in
You have a couple of options for how to configure the settings for Ghost. The "easy" way is to just add the configurations in the
default file. The alternative is to create a separate file for Ghost, with an easily intelligble name (something like
The information you're really after:
Whichever file you chose, here's what you'll need to add:
<VirtualHost *:80> ServerName ghost.example.com DocumentRoot /path/to/ghost/ ProxyPreserveHost on ProxyPass / http://127.0.0.1:2368/ ProxyPassReverse / http://127.0.0.1:2368 </VirtualHost>
Notice that Apache directing all incomming traffic on your desired subdomain to your locally-running Ghost (on default port 2368). You're more than welcome to tinker with any of these settings.
If you chose to create a separate entry rather than dumping everything into the defeault file, you'll need to enable it in Apache. To do this, run:
And to get Apache to recognize these changes, restart it:
service apache2 restart
Assuing that Ghost was already running (that is, internally on localhost), you should now be reach your Ghost installation from the public Internet.
A note about config.js
My blog post about installing Ghost suggests changes to the
config.js file in Ghost's root directory. Using ProxyPass, you can pretty much just leave these settings alone, since Apache will be interfacing with Ghost and relaying traffic. You therefore need only to change the
I first consulted Alberto Corona's 0X1A blog when trying to get Ghost working with Apache on my server. I ran into some troubles, however, when trying to follow his instructions with regard to
config.js (note, too, that as of the time I am writing this, the setting he posted are those of an unmodified the config.example.js file, which I am suggesting should work without changing the
port settings). Alberto also has us attempting to run Forever using the
NODE_ENV=production variable, and I also ran into some trouble with this... but I think my trouble derived precisely from my attempt to change the server IP parameters.
The site How To Install Ghost has a more technical-looking guide, which I saw only after mucking through the process I outline here.
View or Post Comments