Grid Guides

Explore How System On Grid Can Work For You

Grid Guide Topics

How to Install Ghost on Ubuntu 18.04

Table Of Contents


    ## Table of Contents

    – [Introduction](#introduction
    – [Prerequisites](#prerequisites
    – [Installing Node.js and yarn](#installing-node-js-and-yarn
    – [Installing Mysql](#installing-mysql
    – [Installing Ghost CLI](#installing-ghost-cli
    – [Creating Ghost Installation Location](#creating-ghost-installation-location
    – [Installing Ghost](#installing-ghost
    – [Complete the Ghost Setup](#complete-the-ghost-setup
    – [Conclusion](#conclusion

    ## Introduction

    [Ghost](https://ghost.org/ is an open-source publishing platform for creating professional blogs, magazines, and websites. It contains Node.js core API, an Ember.js admin client, and flexible Handlebars.js front end theme SDK.

    In this guide, we will describe how to Install Ghost on Ubuntu 18.04.

    ## Prerequisites

    Ghost system requires minimum 1GB of RAM. If your system has less than 1GB of RAM then you have to create a swap file.

    Your domain name must be pointing to your Public server IP.

    You should have access to an Ubuntu 18.04 server and created a non-root user account with sudo privileges by following our guide, [Initial server setup with Ubuntu 18.04](https://systemongrid.com/support/guides/how-to-do-initial-server-setup-with-ubuntu-18.04.

    Nginx has to be installed using this guide, [How to Install Nginx on Ubuntu 18.04](https://systemongrid.com/support/guides/how-to-install-nginx-on-ubuntu-18.04.

    Firewall to be configured by using the following our guide, How to Set up a Firewall with UFW on Ubuntu 18.04.

    ## Installing Node.js and yarn

    First of all, you have to install Node.js version for Ghost i.e. v8 Carbon LTS. You have to install Node.js from the NodeSource repository.

    You have to enable the NodeSource repository for Node.js v8 using the below command.

    “`
    $ curl -sL https://deb.nodesource.com/setup_8.x | sudo bash –
    “`

    Install Node.js by entering the below command.

    “`
    $ sudo apt install nodejs
    “`

    You can this guide How to Install Node.js on Ubuntu 18.04.

    For installing Yarn, you have to enable the Yarn repository on your system using below commands.

    “`
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list
    “`

    Now the repository gets enabled, Now install yarn using below command.

    “`
    $ sudo apt update
    $ sudo apt-get -o Dpkg::Options::=”–force-overwrite” install yarn
    “`

    ## Installing Mysql

    Ghost supports some Databases like MySQL, MariaDB, and SQLite. We are recommended MySQL for this tutorial because it will be useful when you run Ghost in production mode.

    To Install MySQL package use the below command.

    “`
    $ sudo apt install mysql-server
    “`

    To improve the security of the MySQL installation use below command.

    “`
    $ sudo mysql_secure_installation
    “`

    You have to configure the VALIDATE PASSWORD PLUGIN which is used to verify the strength of the MySQL users passwords. There will be three levels of password validation policy i.e. low, medium and strong. If you don’t want to set up the validate password plugin simply click the ENTER.

    You will be asked to set a password for the MySQL root user. Once you set the root password the script will also ask you to remove the anonymous user, then restrict the root user access to the local machine and remove the test database. You must answer yes to all questions.

    Next, you have to change the authentication method from auth_socket to mysql_native_password, then the Ghost installer can access our MySQL server. For that purpose, you have to log in to MySQL server as the root user.

    “`
    $ sudo mysql
    “`

    Now run the below command which will set a password the MySQL root user when using the mysql_native_password method:

    “`
    mysql>ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘very_strong_pasword’;
    mysql>FLUSH PRIVILEGES;
    “`

    You have to ensure that you change very_strong_password with a strong password.

    ## Installing Ghost CLI

    You have to install Ghost using the official Ghost CLI utility. This utility allows you to install or update Ghost in a single command. Ghost CLI will occur as a npm package. You can install Ghost CLI on your Ubuntu system by using below command.

    “`
    $ sudo yarn global add ghost-cli
    “`

    ## Creating Ghost Installation Location

    We recommend that you have to download and install Ghost in the /var/www/ghost directory which is for the installation location.

    Use the below command to create the directory type:

    “`
    $ sudo mkdir -p /var/www/ghost
    “`

    To change the ownership of the directory to your user, Use the below command.

    “`
    $ sudo chown $USER:$USER /var/www/ghost
    “`

    To set the correct directory permissions, Use the below command.

    “`
    $ sudo chmod 775 /var/www/ghost
    “`

    ## Installing Ghost

    Now you have installed Ghost CLI and all prerequisites are completed, You can start with the installation. You can change to the /var/www/ghost directory.

    “`
    $ cd /var/www/ghost
    “`

    First of all, To start the installation run ghost install command, which will install and configure Ghost. And configure Nginx as a reverse proxy, and secure the site with a free let’s encrypt SSL certificate. To do this run below command.

    “`
    $ ghost install
    “`

    The installer will check your system and then print some warnings. So that you have to type y to continue. Now the installer will download and install the Ghost.

    ![installingghostonubuntu](https://grid.media/assets/images/installing-ghost-on-ubuntu-02132019.png

    Now you will be directed to set your blog URL and your MySQL information. Now you have to provide the root username and password that we have setup in Installing MySQL section. Now you have to use the default database name ghost_prod.

    ![blogandsqlinformation](https://grid.media/assets/images/blog-and-mysql-information-02132019.png

    Now the installer will create a system user named ghost and will ask you that, If you want to create a ghost MySQL user, then type Yes if you required.

    ![ubuntughostmysqluser](https://grid.media/assets/images/ubuntu-ghost-mysql-user-02132019.png

    Now the installer will ask you about Nginx, Confirm it, By entering Yes. If you required.

    ![ubuntughostnginxsetup](https://grid.media/assets/images/ghost-ubuntu-nginx-setup-02132019.png

    After configuring the Nginx, You will be asked to set up SSL. Confirm it by typing yes and the configuration wizard will ask you to enter your email address and then it will generate a free Let’s Encrypt SSL certificate for your domain and configure Nginx.

    ![settingupssl](https://grid.media/assets/images/setting-up-ssl-02132019.png

    Now the installer will ask you if you want to set up a systemd service. Confirm it by typing yes to accept, Now the installer will create a new systemd service called ghost_example.com and enable it to start on boot.

    ![ghostsystemd](https://grid.media/assets/images/ghost-ubuntu-setup-systemd-02132019.png

    Now the installer will set up the database and ask if you want to start Ghost, then enter Yes to confirm it.

    ![startghostonubuntu](https://grid.media/assets/images/start-ghost-on-ubuntu-02132019.png

    ## Complete the Ghost Setup

    Now open your browser, go to your Ghost admin interface at https://IP Address/ghost/ then you will get a below output.

    ![welcometoghost](https://grid.media/assets/images/welcome-to-ghost-on-ubuntu-02132019.png

    Now, Click on Create your account button. Then you will be prompted to Create your account screen. Now you have to enter up your Blog title and also your account Full name, Email address, and password.

    After filling the details you have to click on the Invite your team button. In this page, you have to enter the email addresses of the collaborators. Then you can click on I’ll do this later, take me to my blog! Link. Then you will be redirected to the Ghost Dashboard as below.

    From this dashboard, you can create new posts, add users and change Ghosts configuration.

    ## Conclusion

    In this Guide, we have described how to install a production-ready Ghost instance.