Install Ghost
Tue, Jun 16, 2015 · 3 minute readwebhow to
Short article on how to install the blogging platform Ghost on your own server.
Get a VPS
Doesn’t really matter who from but I’ve found that OVH are pretty reliable.
I use a Debian (Jessie) based VPS, if you use anything else YMMV.
Do some basic server configuration
# Disable root login via SSH
vi /etc/ssh/sshd_config
# Change PermitRootLogin to no
service ssh restart
# Disable root password
passwd -dl root
# Update and upgrade installed packages
apt-get update
apt-get upgrade
# Set your timezone
dpkg-reconfigure tzdata
Create a user
This is the user you would use to administer the server. We can’t login as root anymore so this step is kind of essential.
# Create the user
adduser <your username>
# Add user to sudo group
adduser <your username> sudo
# Set a password
passwd <your username>
From now on login to your VPS using your username, then either:
- Prefix all following commands with ‘sudo’ OR
- Run
sudo -i
to become root and run the commands as is.
Install some required packages
apt-get install sudo
apt-get install zip
apt-get install apache2
# Make sure to set a strong MySQL root password
# OK - don't need PHP or MySQL for Ghost - but they may come in handy.
apt-get install mysql-server
apt-get install php5 php-pear php5-mysql php5-gd
Do some basic package configuration
# Secure the MySQL environment
mysql_secure_installation
# Enable some Apache modules
# Enable Apache SSL
a2enmod ssl
# Enable rewrite module
a2enmod rewrite
# Enable proxy (if you might host multiple Ghost blogs)
a2enmod proxy
a2enmod proxy_http
# Restart Apache
service apache2 restart
Setup Apache virtual host(s)
I use my VPS to run several websites so always setup virtual hosts to separate out the administration.
# Create a directory for the virtual host
cd /var/www
mkdir vhosts
cd vhosts
mkdir <domain name>
I number my virtual hosts and use that number in various places, e.g. log files.
Reduces length of filenames and saves me some typing.
# Create (or edit) the Apache virtual host configuration
cd /etc/apache2/sites-available
vi 999-<your host name>.conf
Example of a virtual host configuration - including the proxy directives which avoid having to specify the port number in the URL.
Note also the use of the Define directive to avoid repeatedly specifying the same information. Means I can start with a template configuration and get a virtual host up and running without any editing mistakes.
Lastly, note the use of the non-standard Ghost port number. This important later on.
<VirtualHost *:80>
Define VHostId 160
Define VHostName <your domain name here>
Define VHostDir /var/www/vhosts/${VHostName}
Define GhostPort 3160
ServerAdmin postmaster@localhost
DocumentRoot ${VHostDir}
ServerName ${VHostName}
<Directory ${VHostDir}>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/${VHostId}-error.log
CustomLog ${APACHE_LOG_DIR}/${VHostId}-access.log combined
ProxyRequests Off
ProxyPass / http://127.0.0.1:${GhostPort}/
ProxyPassReverse / http://127.0.0.1:${GhostPort}/
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from 127.0.0.1
</Proxy>
</VirtualHost>
Install Ghost pre-req’s
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
# This will install node.js and npm
apt-get install nodejs
Install Ghost
cd <vhost dir>
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
unzip -uo ghost.zip
cp config.example.js config.js
vi config.js
Change URL and port
NB: Port must be the same as defined in Proxy section in virtual host configuration file.
npm install --production
npm start --production
Good to go
You should be able to browse to
Just two steps remain …
- Install and configure software to get Ghost running all the time
- Setup scripts and cron jobs for Ghost backups