Recently, Ghost announced version 1.0 of their publishing platform. We've been using the earlier releases for some time at Boardies IT Solutions for our blog and we've been really happy with it, and this continues with Ghost 1.0.
Officially Ghost 1.0 only supports Ubuntu 16.04 with NGINX, however, our servers run CentOS 7 with Apache, but we gave it a try anyway and it looks to work perfectly fine (this blog post is running under Ghost 1.0).
First of all you need to get your server set up before you start installing. First of all, I'd recommend installing any patches that you may have waiting on your server. To do this run the following:
Ensure all patches are installed and we'd also recommend rebooting the server after the patches have been installed.
If you are doing a completely new install you need to add a ghost user, if you already have the previous version of ghost installed then you should already have the ghost user set up.
To add a user run the following:
You need to set up your MySQL database. We're assuming you already have this installed and know how to configure MySQL. Create a database and create the ghost user for the database. The following is an example:
CREATE DATABASE ghost; GRANT ALL PRIVILEGES ON ghost.\* TO 'ghost'@'localhost' IDENTIFID BY your_password
Already have Ghost Installed?
Before doing anything with node or Ghost 1.0, you first need to ensure that you have a backup of your ghost data. Login to your ghost admin pages, go to labs and then click on export. This will download a json file which you can then use on your new ghost installation to import your current blog data.
Shutdown the node service using systemd and then move your current blog folder to a new location, this will ensure you have the original version should you need to rollback.
In order for Ghost to work, you need to have node installed. If you already have it, I'd recommend uninstalling what you have (unless you already have the correct version).
I downloaded the source from NodeJS Source which at the time of writing this was version 6.11.2.
Upload this archive to your server and extract using the following
tar -xvf node-v6.11.2.tar.gz
Once extracted run the following to build and install the source code:
./configure make make install
The above steps, the make in particular, can take quite a while to complete.
Once nodejs is installed, it gets installed in a different place on CentOS than on Ubuntu so if you were try run the ghost installer it would fail.
You can get round this by running the following:
ln -s /usr/local/bin/node /usr/bin/node
The above will create a symlink (symbolic link) so that when ghost tries to run /usr/bin/node it points to the actual location of node which is /usr/local/bin/node.
Now to install ghost create a directory of where the install for it will be and set the ownership to be the ghost user for that directory using the following:
mkdir /var/www/ghost chown ghost:users /var/www/ghost
Now change directory into the ghost directory you created above and run the ghost installer.
The ghost installer will install the necessary files, set up your DB and create the systemd service so that ghost starts when the server starts.
To run the installer, run the following
cd /var/www/ghost npm i -g ghost install ghost install
Note that when you run
ghost install it will give you a warning as you are not on Ubuntu, but say to continue.
The ghost install will also ask you various questions, such as your MySQL user and database name (when entering these make sure they match how you set your database up in the prerequisites.
It will ask you do you want to set up the MySQL user and NGINX, you can say "no" to both of these questions.
Once completed, it will then ask you if you want to start ghost. Say yes and it should be up and running. Now that its running, you need to configure apache to be able to work with it.
Configuring Apache to Work With Ghost
By default Ghost runs on port 2368 and binds to localhost. This is fine, but you need to tell apache how to be able to pass requests from Apache to Ghost.
We're using Virtual Hosts so this is how we're going to explain how to set it up, I'm sure there is likely a way to do this if you are not using virtual hosts, so let us know, and we'll update this post and reference you with your instructions.
Navigate to your virtual hosts configuration file.
<VirtualHost *:80> ServerName blog.example.com ServerAlias blog.example.com ProxyRequests off ProxyPass / http://127.0.0.1:2368/ ProxyPassReverse / http://127.0.01:2368 </VirtualHost>
The above should be realtively simple to understand what is going on, basically when Apache receives a request on port 80 to blog.example.com, it passes the request to localhost on port 2368 and sends a response back to the client, therefore giving you access to the blog.
Make sure to restart after making the change
service httpd graceful
The above will restart apache without causing any downtime, anyone already connected will be unaffected, but new connections after the restart will use the new configuration.
That's it, its now installed and ready to use
Logging in and Importing your Previous Entries
Navigate to where your blog is, in our example
http://blog.example.com/admin. It will ask you to create an account, fill in the details and you'll be logged into the administration area of ghost.
Go to labs and click browse under import and browse to where your json file that you downloaded earlier is located. Once done all of your blog entries should now be available again.
Note: You may want to first delete all content first from the labs page before doing the import.
That's it, we're all done, let us know in the comments what your experience is or any other tips and advice you can offer.