Run a Ghost blog on your server
The internet is a bleak place in the third decade of the 21st century. Away from the walled-garden shouting matches and ego-stroking of the social media sites, you’d be forgiven for thinking that the bulk of the web is an endless desert of SEO optimised buying guides, VPN affiliate sites and filth.
Table of Contents
Well, that’s our experience of it anyway. Gone are the days of stumbling around from site to site, following links from personal blogs to whatever whimsical sites the authors care to link to. But it doesn’t need to be that way. Break away from the usual routine and well-trodden paths, and you’ll find that there are still a few pockets of genuine authentic content, written by authors who want to document their lives without plastering it across Facebook for a handful of Likes, or document their hobbies and passions without selling out to a huge media conglomerate (hey, that’s us!–ED).
Yes folks, independent blogging is back with a vengeance, and with your shiny new VPS, you can be a part of it too! Imagine the delight of a total stranger as they stumble across your blog and are sucked down into your thoughts, musings and oh-so-witty take on life, politics, technology and pets.
Picture their glee as, having bookmarked your words of wisdom and shared it with their friends, they move on to yet more discoveries through your expertly curated set of links to other blogs worth their time.
So what is a blog? You know damn well what a blog is. The correct question is, “How do I choose what blogging software to use?” with the possible additional question, “How do I set it up?” We’ll address both now.
Down at the most basic level, your blog can be a simple text document written in nano, mousepad, kate or whatever. You can put it in the root of your VPS and update it by simply adding more text to the top. It works, it’s simple, it’s super-quick and it’s an almost no-knowledge of way of getting your thoughts out into the world. The downside is that a text file is limited to text only. No images, no links, and your blog is unlikely to be discovered by accident or happenstance.
The next possibility is to do it in HTML by hand, with the added option of using a Static Site Generator (see Roundup LXF282) such as Jekyll to make creation and updates a walk in the park. But SSGs are last year’s hot topic, and while they hold a treasured place in the hearts of everyone at Linux Format, it seems like a severe underuse of the resources of our mighty VPS.
WordPress, schmerdPress
What we want is a content management system. In contrast to static sites which require a certain amount of HTML or markdown knowledge and a hefty dollop of organisational skill, a CMS takes care of all almost all of the nuts and bolts which result in what you see on the resulting webpages.
It’s entirely possible to create and manage a website without any knowledge of anything beyond the words you want to write about your chihuahua’s pregnancy, and the adorable (or yucky) pictures you choose to illustrate the same.
Beyond a few hold-out sites which are stuck in the Stone Age (linuxformat.com?–ED), almost every website in existence uses a CMS. The one you’ll most likely have seen most of – or even have experience with yourself – is WordPress. It’s simple, it’s free, and installation is as easy as wget-ting a file into your document root and unzipping. It doesn’t get much simpler than that, which is why it is the power behind more than one third of the sites currently in existence.
But in the same way that viruses are usually tailored for Windows systems, the very ubiquity of WordPress makes it vulnerable to attack. If you’ve ever run a website, whether WordPress or not, you will have noticed from your access logs that most of the automated login attempts are tailored for WordPress, and if you really feel like descending into a nightmare spiral of paranoia, search “WordPress hack” on YouTube and watch as ‘security experts’ breach the admin dashboard and manage to bring up a shell with root access to the host system. Then there are the problems with plug-ins, where villains will buy up a company behind a popular one and turn users’ WordPress blogs into malware-spewing trap sites. In short, WordPress attracts hackers like our late, much-lamented cat attracted fleas.
Woooooo, a Ghost!
Ghost is a Content Management System every bit as competent as WordPress, and extra spooky. In our expert opinion, Ghost’s low penetration into the Open Source CMS market makes it a much lower profile target for hacks. It also has some killer features that WordPress is lacking.
Vulnerabilities aside, Ghost is (in our opinion) a far better blogging platform than WordPress, because that is its sole raison d’etre. You won’t find any e-commerce plug-ins for Ghost, and everything about the interface is dedicated to creating a comfortable writing experience for the blogger, and a clean, well laid-out reading experience for your audience.
Who ya gonna call?
Have we managed to convince you yet? Great! You now know what Ghost is and you’ve decided it is the medium through which the world needs to hear your words.
We’re going to assume that you’ve read and thoroughly digested our previous two VPS features in LXF281/LXF282 (https://bit.ly/lxf281lxfserver and https://bit.ly/lxf282lxfserver). If not, don’t worry, read them at the Archive and then get back to us. All done?
Next you need to decide on a domain or subdomain for your ectoplasmic blog. We went with ghost.lxf.by, and followed our VPS provider’s instructions to link it with the VPS. Unlike WordPress, Ghost does not simply allow you to dump a bunch of files into the document root, point Apache in its general direction and access it through ports 80 and 443.
As with an increasing amount of web-facing software, Ghost takes a more ethereal approach, operating on its own port – in this case 2268. Your server will need to proxy incoming traffic on 80 and 443 so that it finds its way to 2268.
If you failed to follow our advice in the first tutorial of this instalment and chose Nginx over our heartfelt recommendation of Apache, then congratulations! The Ghost installer script is designed to configure an installation on Nginx automatically. Feel free to skip ahead. Apache users will need to activate a couple of mods to enable Apache to do the proxying:
sudo a2enmod proxy proxy_http
and then restart Apache:
sudo service apache2 restart
You’ll then need to create a conf file so that Apache knows what it’s supposed to be doing.
sudo nano /etc/apache2/sites-available/ghost.conf
Inside the conf, you will need to tell Apache what port to listen on, the name of the server, and what port to proxy requests to. Ours looks like this:
Then enable the conf with
sudo a2ensite /etc/apache2/sites-available/ghost.conf and restart Apache once more. You will need to give Ghost its own database, so open up Maria with:
sudo mariadb
Then enter each of these commands which will create a user called ghost on a new database called ghost and allow the new user to use the new database. Feel free to choose your own wacky names.
Remember to keep the details safe and secure for later, and not on Post-it note stuck to your monitor.
To actually install the Ghost CMS software, there are only two additional dependencies: node.js and node package manager (npm).
Unfortunately the versions of node in the default repositories are not compatible with Ghost, nor is the latest version (v16.10.0). You will need to install the nodesource PPA first. Head over to your home directory and do:
Run sudo apt-get install -y nodejs to install Node.js 14.x and npm. Note, there is no need to run apt update before you do this as it is run as part of the setup script. Check that the install was a success by querying the version number with:
node -v
and your VPS should return a response of:
v14.18.0
Now it’s time to install the tool which will install Ghost:
sudo npm install ghost-cli@latest -g
After a few seconds with a swanky ASCII progress bar, you’ll be back on the command line, Finally, we can actually run the command which will (we promise) install Ghost.
ghost install
In the time it would take to hold a reasonably short seance (or a cup of tea) with the spirit of a deceased pet, the install will suck down everything it needs and at long last get installation underway.
Nearly there…
You’ll be asked for your blog URL (enter http rather than https as we have not yet set up our SSL certs), your MySQL hostname (localhost), your MySQL username and password.
The more keen-eyed among our readership will have noted a number of warning messages and skipped steps during the setup. These (mostly) relate to Nginx, which you will recall is not present on the LXF server as we opted for Apache instead. If you did choose Nginx, all should be peachy.
Visit your new blog at the domain you specified and fill in the name and email address fields and think up a cool title. Then close the tab and head back into terminal again because it’s time to secure your blog against the ne’er-do-wells who want to listen in on your traffic and attack your readers.
With security topmost in our mind, we ran sudo certbot, entered our email address and declined to join the EFF mailing list (because we’re already on it). Certbot gave us a list a short list of domains for which certificates could be obtained.
We selected the relevant one, and opted for automatic redirection – meaning that anyone typing blog.lxf.by or http://blog.lxf.by would be magically transported over to https://blog.lxf.by. That’s it. Done. Simple.
Ghosts in the haunted mansion
Cold shivers down your spine, and mysterious creaking doors aside, Ghost is a pleasure to use and also incredibly customisable.
The default page comes pre-populated with a headline story, with the oh so evocative title of “Start here for a quick overview of everything you need to know”, and six equally spooky stories including such thrillers as “Customizing your brand and design settings”, the spin-chilling “Building your audience with subscriber signups” and the terrifying “Selling premium memberships with recurring revenue”.
We’re sure that some of our readers would love to avail themselves of these capitalist pieces, but it’s not us. We’re just here to build a cool-looking blog to show off our burgeoning bunch of bonsai bushes to the world. The layout is nice though, and the articles on customisation are certainly worth a read.
On the dashboard immediately after you log in through your.site/ghost, there’s a large black banner with a green button marked ‘Start setup guide’. This is the best first step you can take to alter the look and feel of your Ghost blog, and clicking it will take you on a step-by-step journey through the aesthetic details. We chose do do away with the fuchsia accent highlight in favour of a dark, mysterious black, and the background pastel gradient image was tossed away in favour of a Matrix-esque image of green zeros and ones cascading down a black background. Very Noughties.
The front page was still looking dull with the default non-images which came bundled with the installation, so we downloaded a fistful of Linux-related images with Creative Commons licences, and dived into the post editor to switch them over.
Get writing
Writing in Ghost is simple and intuitive. Creating a new post is as simple as pressing the + symbol on the lefthand side. The layout is a plain white page, with an area for the title and another area for the text.
Additional elements can be added simply by pressing the + button prompt and choosing whether you’d like an image, a text block, HTML, a gallery, or embeds for the most common media providers: YouTube, Spotify and so on. If you’ve ever used the premium ‘WP bakery’ WordPress plug-in, you’ll be instantly at home – except moreso, because Ghost is considerably quicker and a lot easier to use.
Over in the Integrations section, you’ll find that Ghost plays nicely with a huge range of tools, from Plausible analytics to Slack. The amount of difficulty involved in setting up each of these varies, but does tend to be on the very simple side.
Hopefully, by now you’ll have a good-ish feel for the way Ghost works, and can find your way around it without too much difficulty. For such a sophisticated piece of software it’s surprisingly easy to get a grasp on how it works – which is the true benchmark of a great project, we suppose.
OTHER DEDICATED BLOGGING SOFTWARE TO CONSIDER
WordPress and Ghost aren’t the only Content Management Systems available for your Virtual Private Server, but we really like how powerful and easy to customise they are, as well as the support available from their online communities. The web is a varied place and no one size fits all. If Ghost doesn’t tickle your fancy and you’re turned off by the ubiquity of WordPress, there are hundreds of alternatives for you to try.
Our favourites from among the rest include BigTree CMS (www.bigtreecms.org), a straightforward, well documented and capable CMS written with PHP and MySQL. Silver Stripe (www.silverstripe.org) advertises itself as “the intuitive content management system and flexible framework loved by editors and devs alike”. REDAXO (www.redaxo.org) comes with some fabulous features, but the documentation is written entirely in German, so unless your fairly fluent, you should probably stay away. October CMS (https://octobercms.com) is based on Laravel to offer an excellent modular system and plenty of free plugins.
New projects are coming online all the time as users wanting a very particular feature set create their own forks or create their own CMS from scratch, so it’s always a good idea to keep an eye on the news.
THE GHOST WITH 1,000 FACES
As with any new toy or gadget, it’s easy to become bored quickly once you’ve mastered the basics, and you want more things to tinker with. Understandable; it’s either that or crack on with the hard work of writing 3,000 word posts on the nature of your own personal brand of spirituality.
Fear not! You can put off the inevitability of doing any actual writing work by giving your blog a complete makeover. Ghost’s overall look is governed by themes. The default theme is called Casper (for obvious reasons), and to our mind, it’s pretty good. Everything is laid out nicely, and it’s a pleasure for your visitors to view. Head over to https://ghost.org/themes and you’ll see hundreds of themes which can completely change the way your blog appears. There are themes suitable for photo galleries, bulletins, newsletters, travel journals and more.
Some of these themes are free. Most are not, and the highest price we saw on the marketplace was (gulp) $149. We’re not criticising here – people work hard to create these themes, and deserve to be compensated for their toil – but we chose London from the 24 available free themes. We’re not suggesting that we’re cheap here at LXF Towers, but, well, we drink the free coffee offered here.
The creators of the London theme describe it as “A bold, minimal theme for Ghost, focused on clean typography & beautiful imagery”, and it is. We installed it by the simple expedient of clicking install on the theme’s page, entering the address of our blog, clicking install again, then activate. Honestly, it couldn’t have been simpler.
In our opinion, the new theme looks better than fabulous. Now all we need to do is actually write some fascinating copy for our legion of fans.
QUICK TIP
You may find (as we did) that some of your standard terminal shortcuts may not work with your VPS. Ctrl+ L clears the screen on our home machine, but results in a mess when connected to the VPS. We had to go old-school and type out the word ‘clear’.
QUICK TIP
Some VPS providers such as Digital Ocean offer a one-click web install for Ghost, meaning that you can skip practically all of these steps. You could take the easy option, but where’s the fun in that?
QUICK TIP
When publishing to the web, you need to consider copyright concerns. You should only use images under a Creative Commons licence (and abide by the terms of that licence), or which are in the public domain. We’re not joking – some photographers make more by suing over copyright issues than by selling photos. Try Flickr or Wikimedia Commons.
This is truly fascinating and helpful information.
I appreciate you sharing this information.
share your knowledge with us
Please let us know.
Thank you for providing this information.