Chapter 2. Manual Installation and Configuration of Ghost

In this chapter, we will discuss how to install Ghost manually on your computer or a VPS. Given installing on a VPS requires many of the same steps as a local installation, you'll also see what additional steps you need to take to install Ghost manually on a VPS, based on the two most popular operating systems VPS hosts tend to run: Ubuntu and CentOS.

If you are new to using the command line, you may want to look at one of the automated installs instead of installing manually, because it can get a little tricky. We are going to give you all the commands you will need, but it may get complicated for someone who has never used the tools before.

This chapter covers the following topics:

  • Manually installing Ghost
    • Using the command line and SSH
    • CentOS (local and VPS)
    • Ubuntu (local and VPS)
    • OSX (local)
    • Windows (local)
  • Additional configuration
    • Pointing a custom domain to your blog
    • Hosting multiple blogs on a single VPS
    • Keeping Ghost running on a VPS
    • Upgrading Ghost
  • Troubleshooting and finding help

Manually installing Ghost on your local computer

In this section, we will detail how to install Ghost locally on your personal computer and on your web hosting company's server. We will be covering Ubuntu, CentOS, Mac OS X, and Windows. The steps to install Ghost are largely the same whether installing locally on your personal computer or on a remote server. However, there are some key differences that we will highlight.

Command-line interface and SSH access

In order to install Ghost manually, a command-line tool and, if you are using a VPS, an application for Secure Shell (SSH) access is needed. If you are using Mac OS X or Linux, you can use the Terminal application. On Mac OS X, it is located in your Applications | Utilities folder. For Windows, you need to download an application in order to use SSH; however, if you're installing locally, you can use the command prompt by navigating to Accessories | Command Prompt. For SSH access, we suggest using Putty (http://www.putty.org/).

The majority of steps will be performed using the command line, and we provide the exact command that needs to be executed. Occasionally, you will need to type in part of a command. For example:

tar -xzf node-latest.tar.gz
cd [name of expanded node directory]

In the first command, when we expand node-latest.tar.gz, the name of the folder that will be created is unknown, but in our case, it is called node-v0.10.25. Therefore, our change directory command would look like this:

cd node-v0.10.25/

You can see an example of this in the following screenshot:

Command-line interface and SSH access

Note

For those new to using command-line interface, it's beyond the scope of this book to fully explore command-line operations—though we'll be demonstrating all the commands you need to execute specific steps throughout. If you want to learn more about this, see the following link (don't be put off by the title! It's a great way for beginners to learn how to leverage the power of the command line):

http://cli.learncodethehardway.org/book/

Identifying your VPS operating system

If you have a VPS but are unsure what operating system is installed, you can SSH into your VPS, and run uname -a to determine if it is Ubuntu or CentOS, as shown in the following example:

[email protected]:~# uname -a
Linux 192.168.0.13 3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

On Ubuntu, running uname -a will output something similar to the one shown in the following screenshot:

Identifying your VPS operating system

On CentOS, the output will look like this:

[email protected] [~]# uname -a
Linux server 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Here's the screenshot as well:

Identifying your VPS operating system

Installing Ghost on Ubuntu (VPS and local)

We need to perform the following steps to install Ghost on Ubuntu OS. These steps will work on all versions of Ubuntu 12.04 and higher:

  1. First, make sure your Ubuntu operating system is up to date:
    sudo apt-get update
    sudo apt-get upgrade
    
  2. Next, install the tools needed to compile Node.js:
    sudo apt-get install build-essential zip
    
  3. Download and install Node.js:
    cd /tmp/
    wget http://nodejs.org/dist/node-latest.tar.gz
    tar -xzf node-latest.tar.gz
    cd [name of expanded node directory]
    ./configure
    make
    sudo make install
    
  4. Create a Ghost user:
    sudo adduser ghost
    
  5. Download and install Ghost:
    sudo mkdir -p /var/www/
    cd /var/www/
    sudo wget https://ghost.org/zip/ghost-latest.zip
    sudo unzip -d ghost ghost-latest.zip
    sudo chown -R ghost:ghost /var/www/ghost/
    sudo rm ghost-latest.zip
    
  6. Switch to the ghost user:
    su - ghost
    
  7. Install Ghost:
    cd /var/www/ghost
    npm install --production
    
  8. Configure Ghost (skip this step if installing locally):
    vi config.example.js 
    
  9. In the Production section, change host: '127.0.0.1', to:
    host: '0.0.0.0',
    
  10. Save and exit
  11. To start Ghost, run:
    npm start --production
    

After running the command in step 11, you should see an output that says Ghost is running…. You're now running Ghost!

Installing Ghost on Ubuntu (VPS and local)

This means that Ghost has started successfully and you can now browse to your Ghost website. If you installed Ghost locally and did not edit the config.js file, type the 127.0.0.1:2368 URL into your browser, and you will see your Ghost blog. If you edited your config.js file, head to the URL or the IP address where Ghost is set up to run it.

Now that you see your Ghost home page, add /ghost/ to the end of the URL to create your Ghost admin user (for example, 127.0.0.1:2368/ghost/ or <yourdomain>.com/ghost/).

If you run into any errors with starting up Ghost, see our Troubleshooting section at the end of this chapter.

Configuring Ghost on Ubuntu for VPS

We will be using Nginx, a popular web server software, to run on port 80, which will then proxy requests to port 2368, the port that Ghost will be running on. This section assumes that you have already purchased a domain name from a registrar such as NameCheap and have configured the domain to point to your VPS. If you need assistance setting up your domain name, we would recommend contacting your domain registrar and they will assist with the configuration. To configure Ghost on Ubuntu, perform the following steps:

  1. Install Nginx:
    sudo apt-get install nginx
    
  2. Configure Nginx to proxy all requests to port 80 to localhost:2368 by placing the following configuration in /etc/nginx/conf.d/ghost.conf:
    server {
      listen 80;
      server_name example.com;
    
      location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
      }
    }
  3. Restart Nginx to load the new configuration:
    sudo service nginx restart
    

Installing Ghost on CentOS (VPS and local)

Perform the following steps:

  1. Update your operating system:
    sudo yum update
    
  2. Install the additional packages that are needed to compile Node.js:
    sudo yum groupinstall development
    
  3. Download and install Node.js:
    cd /tmp/
    curl -O http://nodejs.org/dist/node-latest.tar.gz
    tar -xzf node-latest.tar.gz
    cd [name of expanded node directory]
    ./configure
    make
    sudo make install
    
  4. Create a Ghost user:
    sudo useradd ghost
    
  5. Download and install Ghost:
    sudo mkdir -p /var/www/
    cd /var/www/
    curl -L -O https://ghost.org/zip/ghost-latest.zip
    unzip -d ghost ghost-latest.zip
    sudo chown -R ghost:ghost /var/www/ghost/
    sudo rm ghost-latest.zip
    
  6. Switch to the Ghost user:
    su - ghost
    
  7. Install Ghost:
    cd /var/www/ghost/
    npm install --production
    
  8. Configure Ghost (skip this step if installing locally):
    vi config.example.js 
    
  9. In the Production section, change host: '127.0.0.1', to:
    host: '0.0.0.0',
    
  10. Save and exit
  11. To start Ghost, run:
    npm start --production
    

After running the command in step 11, you should see an output that says Ghost is running…. You're now running Ghost!

Installing Ghost on CentOS (VPS and local)

This means that Ghost has started successfully and you can now browse to the Ghost website. If you installed Ghost locally and did not edit the config.js file, type the URL 127.0.0.1:2368 into your browser, and you will see your Ghost blog. If you did edit your config.js file, head to the URL or IP address where Ghost is set up to run.

Now that you see your Ghost home page, add /ghost/ to the end of the URL to create your Ghost user (for example, 127.0.0.1:2368/ghost/ or example.com/ghost/).

If you run into any errors with starting up Ghost, see our Troubleshooting section at the end of this chapter.

Configuring Ghost on CentOS for VPS

We will be using Nginx, a popular web server software, to run on port 80, which will then proxy requests to port 2368, the port that Ghost will be running on. This section assumes you have already purchased a domain name from a registrar such as NameCheap and have configured the domain to point to your VPS. If you need assistance setting up your domain name, we would recommend contacting your domain registrar and they will assist with the configuration.

  1. Install Nginx:
    sudo yum install nginx
  2. Configure Nginx to proxy all requests to port 80 to localhost 2368 by placing the following configuration in /etc/nginx/conf.d/ghost.conf:
    server {
      listen 80;
      server_name example.com;
    
      location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host   $http_host;
        proxy_pass     http://127.0.0.1:2368;
      }
    }
  3. Restart Nginx to load the new configuration:
    sudo service nginx restart
    

Installing Ghost on Mac OS X (local)

We need to perform the following steps to install Ghost on Mac OS X:

  1. Update your operating system by clicking on the apple in the upper-left-hand corner and clicking on Software Update.
  2. Go to http://nodejs.org/download/ and download the .pkg Macintosh Installer. Double-click on the file that was downloaded and go through the installation process, selecting all of the default values.
  3. Execute the following commands on the command line in the Terminal app (located in /Applications/Utilities):
    mkdir -p ~/ghost
    cd ~/ghost
    curl -L -O https://ghost.org/zip/ghost-latest.zip
    unzip ghost-latest.zip
    rm ghost-latest.zip
    npm install --production
    

Configuring Ghost on OS X

To configure Ghost on OS X, perform the following steps:

  1. We are going to be making changes to the Ghost configuration file. If you just plan to host Ghost locally on your own computer and do not want to allow access from anywhere else, you can skip this step. If you are installing Ghost on a remote server or want to allow access beyond your personal computer, this step is necessary.

    To make the configuration file, we're going to use the vi text editor. For a list of vi commands visit http://www.lagmonster.org/docs/vi.html.

    cp config.example.js config.js 
    vi config.js
    
  2. In the Production section, note the following sections:
    url: 'http://my-ghost-blog.com',
    and
    host: '127.0.0.1',  
    port: '2368' 
    
  3. Replace the preceding code with the following one:
    url: '[your Ghost URL or IP]',
    and
    host: '0.0.0.0',  
    port: '80'
    

    Note

    Check the example config.js in the ZIP file that came with this book to see what it should look like if you are unsure what to change.

  4. To start Ghost run:
    npm start --production
    

After running the command in step 4, you should see an output that says Ghost is running…. You're now running Ghost on OS X!

Configuring Ghost on OS X

This means that Ghost has started successfully and you can now browse to the Ghost website. If you installed Ghost locally and did not edit the config.js file, type the 127.0.0.1:2368 URL into your browser, and you will see your Ghost blog. If you edited your config.js file, head to the URL or IP address where Ghost is set up to run it.

Now that you see your Ghost home page, add /ghost/ to the end of the URL to create your Ghost user (for example, 127.0.0.1:2368/ghost/ or <yourdomain>.com/ghost/).

If you run into any errors with starting up Ghost, see the Troubleshooting section at the end of this chapter.

Installing Ghost on Windows (local)

To install Ghost on a Windows OS, we need to perform the following steps:

  1. Update your operating system by navigating to Control Panel | System and Security | Windows Update | Check for updates.
  2. Go to http://nodejs.org/download/ and click on the Windows Installer to download the .msi installer. Once the download has completed, run the installer, selecting all of the default values.
  3. Now go to the http://ghost.org, log in, and click on the blue Download Ghost Source Code button.
  4. In the location of your choice, create a folder called Ghost and expand the contents of the ghost.zip file into it.
  5. Now, open the Node.js command prompt, which can be found in your Start menu. (There is a Node.js app and a Node.js command prompt. Make sure you open the command prompt.)
  6. Change the directory to the Ghost folder you created:
    cd [ path to where you have created the Ghost folder ]
    
  7. Now install Ghost:
    npm install --production
    

Configuring Ghost on Windows

To configure Ghost, perform the following steps:

  1. We are going to be making changes to the Ghost configuration file. If you just plan to host Ghost locally on your own computer and do not need to allow access from anywhere else, you can skip this step. If you are installing Ghost on a remote server or want to allow access beyond that computer, this step is necessary.
  2. Inside the Ghost folder, there is a file called config.example.js. Open this file in any text editor and change the following sections:
    url: 'http://my-ghost-blog.com',
    

    and

    host: '127.0.0.1',  
    port: '2368'  
    

    to:

    url: '[your Ghost URL or IP]',
    

    and

    host: '0.0.0.0',  
    port: '80'
    
  3. Save this file as config.js and exit the text editor.

    Note

    Check the example config.js in the .zip file that came with this book to see what it should look like if you are unsure what to change.

  4. Now, to start Ghost run:
    npm start --production
    

After running the command in step 4, you should see an output that says Ghost is running….

Configuring Ghost on Windows

This means that Ghost has started successfully and you can now browse to the Ghost website. If you installed Ghost locally and did not edit the config.js file, type the 127.0.0.1:2368 URL into your browser, and you will see your Ghost blog. If you edited your config.js file, head to the URL or IP address where Ghost is set up to run it.

Now that you see your Ghost home page, add /ghost/ to the end of the URL to create your Ghost user (for example, 127.0.0.1:2368/ghost/ or example.com/ghost/).

If you run into any errors with starting up Ghost, refer to the Troubleshooting section at the end of this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset