|
| 1 | +--- |
| 2 | +author: |
| 3 | + name: Elliot Blackburn |
| 4 | + |
| 5 | +description: 'Install, configure, and optimize the Ghost blogging application your Linode.' |
| 6 | +keywords: 'Ghost,install Ghost,Ghost on Linode,how to configure Ghost' |
| 7 | +license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' |
| 8 | +modified: Wednesday, November 29, 2016 |
| 9 | +modified_by: |
| 10 | + name: Elliot Blackburn |
| 11 | +published: 'Wednesday, November 29, 2016' |
| 12 | +title: Install Ghost on Ubuntu 16.04 |
| 13 | +--- |
| 14 | + |
| 15 | +Ghost is a relatively new publishing platform. Its simplistic design and focus on blogging makes it a popular choice for those looking to share written content, and it is well equipped for use by individuals or small groups. This guide will take you through the installation and configuration of Ghost along with nginx, on a Linode running Ubuntu 16.04 LTS. |
| 16 | + |
| 17 | +{: .note} |
| 18 | +> |
| 19 | +>This guide is written for a non-root user. Commands that require elevated privileges are prefixed with `sudo`. If you're not familiar with the `sudo` command, you can check our [Users and Groups](/docs/tools-reference/linux-users-and-groups) guide. |
| 20 | +
|
| 21 | +## Before you Begin |
| 22 | + |
| 23 | +1. This guide assumes that you've followed the steps in our [Getting Started](/docs/getting-started) and [Securing Your Server](/docs/security/securing-your-server) guides. |
| 24 | + |
| 25 | +2. Ensure that your system is up to date: |
| 26 | + |
| 27 | + sudo apt-get update && sudo apt-get upgrade |
| 28 | + |
| 29 | +## Install Node.js |
| 30 | + |
| 31 | +In this section, you'll use a tool called *nvm* (node version manager) to install Node.js on your Linode. |
| 32 | + |
| 33 | +1. Install the `build-essential` and `checkinstall` packages: |
| 34 | + |
| 35 | + sudo apt install build-essential checkinstall |
| 36 | + |
| 37 | +2. Use cURL to install nvm. This example will install nvm v.0.33.1, which is the current version as of this writing. You can check [here](https://github.com/raw/creationix/nvm/) to ensure that you download the most recent version. |
| 38 | + |
| 39 | + curl -o- https://github.com/raw/creationix/nvm/v0.33.1/install.sh | bash |
| 40 | + |
| 41 | +3. Now that nvm is installed, you're ready to use Node.js. [Ghost currently recommends and supports Node.js version 4.2.x](http://support.ghost.org/supported-node-versions/), so you'll use that: |
| 42 | + |
| 43 | + nvm install 4.2 |
| 44 | + |
| 45 | +## Install and Configure Nginx |
| 46 | + |
| 47 | +Next you'll configure nginx to receive requests, and pass them along to Ghost. |
| 48 | + |
| 49 | +1. Install nginx. |
| 50 | + |
| 51 | + sudo apt install nginx |
| 52 | + |
| 53 | +2. Move into the nginx configuration directory and remove the default site configuration, as we will make our own. |
| 54 | + |
| 55 | + cd /etc/nginx/ |
| 56 | + sudo rm sites-enabled/default |
| 57 | + |
| 58 | +3. Use the editor of your choice to create a new file under `/etc/nginx/sites-available/ghost`. This example will use `nano`: |
| 59 | + |
| 60 | + sudo nano /etc/nginx/sites-available/ghost |
| 61 | + |
| 62 | +4. Paste the following configuration code into the file. Change `example.com` to the domain name that you wish to use for your blog: |
| 63 | + |
| 64 | + {: .file} |
| 65 | + /etc/nginx/sites-available/ghost |
| 66 | + : ~~~ conf |
| 67 | + server { |
| 68 | + listen 80; |
| 69 | + |
| 70 | + server_name example.com; |
| 71 | + |
| 72 | + location / { |
| 73 | + proxy_set_header X-Real-IP $remote_addr; |
| 74 | + proxy_set_header Host $http_host; |
| 75 | + proxy_pass http://127.0.0.1:2368; |
| 76 | + } |
| 77 | + } |
| 78 | + ~~~ |
| 79 | + |
| 80 | + Once you've made the necessary changes, save and close the file. |
| 81 | + |
| 82 | +6. Symlink the `sites-available` configuration into `sites-enabled`: |
| 83 | + |
| 84 | + sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/ghost |
| 85 | + |
| 86 | +7. Restart nginx |
| 87 | + |
| 88 | + sudo systemctl restart nginx |
| 89 | + |
| 90 | +## Install Ghost |
| 91 | + |
| 92 | +Now you're ready to install Ghost. This example will use Ghost version `0.11.7`, however you can find the most recent version [here](https://ghost.org/developers/). |
| 93 | + |
| 94 | +1. Move to your home directory, download the latest Ghost release as a zip file, and install `unzip`: |
| 95 | + |
| 96 | + cd ~/ |
| 97 | + sudo wget https://ghost.org/zip/ghost-0.11.7.zip |
| 98 | + sudo apt install unzip |
| 99 | + |
| 100 | +2. Create a new `ghost` directory, and unzip the package to it: |
| 101 | + |
| 102 | + mkdir ghost |
| 103 | + unzip -d ghost ghost-0.11.7.zip |
| 104 | + |
| 105 | +3. Use `npm` with the `--production` flag to install the modules needed to run Ghost in production mode: |
| 106 | + |
| 107 | + cd ghost |
| 108 | + npm install --production |
| 109 | + |
| 110 | +## Configure Ghost |
| 111 | + |
| 112 | +1. Copy the example configuration file to the default location: |
| 113 | + |
| 114 | + cd ~/ghost |
| 115 | + cp config.example.js config.js |
| 116 | + |
| 117 | +2. Open the new configuration file with a text editor: |
| 118 | + |
| 119 | + nano config.js |
| 120 | + |
| 121 | +3. Edit the `url` section, replacing "example.com" with the URL or IP address that you chose previously: |
| 122 | + |
| 123 | + {: .file-excerpt} |
| 124 | + ~/ghost/config.js |
| 125 | + : ~~~ javascript |
| 126 | + var path = require('path'), |
| 127 | + config; |
| 128 | + |
| 129 | + config = { |
| 130 | + // ### Production |
| 131 | + // When running Ghost in the wild, use the production environment |
| 132 | + // Configure your URL and mail settings here |
| 133 | + production: { |
| 134 | + url: 'http://example.com', |
| 135 | + mail: { |
| 136 | + // Your mail settings |
| 137 | + }, |
| 138 | + (...) |
| 139 | + }, |
| 140 | + |
| 141 | + (...) |
| 142 | + ~~~ |
| 143 | + |
| 144 | + When you're finished, save your changes and exit the editor. |
| 145 | + |
| 146 | +5. Install the npm package **forever**, which will ensure that Ghost runs continuously: |
| 147 | + |
| 148 | + npm install -g forever |
| 149 | + |
| 150 | +6. Run Ghost in production mode using forever: |
| 151 | + |
| 152 | + NODE_ENV=production forever start index.js |
| 153 | + |
| 154 | +Now that Ghost is running, you should be able to see your blog in a browser by visiting the web address that you entered in your configuration files, in place of `http://example.com`. |
| 155 | + |
| 156 | +### Complete Setup |
| 157 | + |
| 158 | +To complete the setup process, navigate to the Ghost configuration page by appending `/ghost` to the end of your blog's URL. This example uses `example.com/ghost`. |
| 159 | + |
| 160 | +1. You should see the following page. Click on **Create your Account**: |
| 161 | + |
| 162 | + [](/docs/assets/ghost-welcome.png) |
| 163 | + |
| 164 | +2. Enter the required information to create a user, password, and blog title: |
| 165 | + |
| 166 | + [](/docs/assets/ghost-create-account.png) |
| 167 | + |
| 168 | +3. Next you'll be prompted to invite additional members to your team. If you'd prefer to skip this step, click **I'll do this later, take me to my blog!** at the bottom of the page. |
| 169 | + |
| 170 | + [](/docs/assets/ghost-invite-team.png) |
| 171 | + |
| 172 | +4. You'll see the following page: |
| 173 | + |
| 174 | + [](/docs/assets/ghost-getting-started.png) |
| 175 | + |
| 176 | + From here, you can start configuring your blog from the **Settings** section, or create your first post by clicking **New Post**. To start changing the appearance of your blog, see Ghost's [theme](http://themes.ghost.org/) documentation. |
0 commit comments