Building Ghost CRM in Linux in Virtualbox.

Building Ghost CRM in Linux in Virtualbox.

What is the purpose of this post? The primary driver is to show how to install Ghost CRM a blogging platform locally. However its written to show how to do the install locally using Virtualbox. As i go through it I'll keep updating the notes to explain what is happening and why.

Version

Date

Change

Notes

1.0 2 Dec 2020 Initial Post Initial Post

Please be aware, these instructions are for a local install and are not fit for Production systems. They are designed to provide a flavor and a test system.

Please also be aware I have provided references at the end of the post for websites i have lifted text and images from.

Disclaimer
There are spelling mistakes, grammar errors on this post, i'm a single person, trying to get words down on a page and do not have a copy editor. If your issue is with something technical, please discuss. I'm happy to make a change.

Setup Virtualbox

What is Virtualbox?

At a very high level Virtualbox is an application you can run on your computer which allows you to run other computers in your computer.

As an example, you may run Windows as the Operating system on your computer. You may want to try Ubuntu but don't want to install Ubuntu onto your computer. You can install Virtualbox on Windows and install a full copy of Ubuntu inside Virtualbox.

This guide uses Virtualbox for you to test installing and running GhostCRM on your local machine. Its also possible to skip this section and go to the Install Ubuntu Linux

Install Virtualbox

First you will need to download Virtualbox which you can do from here

Downloads – Oracle VM VirtualBox

In this example you should download the Windows Hosts

Also download the Extention pack as this provides better experience overall when installed

 

The Installation is covered really well in this video

Then we need to install the extension pack, again there is a good video here explaining how to do this and why.

Open VirtualBox, then open VirtualBox preferences (Tools > Preferences) by clicking the appropriate icon with your mouse or by pressing Ctrl+G on your keyboard.

How to install VirtualBox Extension Pack – opening VirtualBox preferences

In the Preferences window, go to the Extensions section. After a fresh installation of VirtualBox, there are no extensions packages installed. Click the Add a new package button (the icon with a green plus) to add the extension pack.

How to install VirtualBox Extension Pack – adding the extension package

Browse the file you have downloaded above. In this case, the name of the file is Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack.

How to install VirtualBox Extension Pack – browsing the package in Windows

VirtualBox notifies you that you are about to install a VirtualBox extension pack. Confirm the installation and click the Install button.

How to install VirtualBox Extension Pack – the installation process

Read the license agreement and hit Agree to continue installation. Wait a few seconds while the files are being copied. If everything is OK, you will get the message that Oracle VM VirtualBox Extension Pack was installed successfully. After closing this notification window, you will see VirtualBox Extension pack in the list of extension packages.

Now you know how to install VirtualBox Extension Pack on Windows.

At this point your Virtualbox is installed and you need to download and install Ubuntu Server into Virtualbox.

Install Ubuntu Linux

What is Ubuntu?

Ubuntu is just like Windows and MacOS an Operating system from a family of Operating systems called Linux. Ubuntu is often considered one of the easier versions of Linux to use as there are so many places to get help with it on the internet.

For the purposes of this tutorial we will use the "Server" version of Ubuntu, it is a version which comes with no point and click interface, and is operated by running text based commands.

Ubuntu is also free, and i'd really recommend downloading the desktop version and giving it a try in Virtualbox after this tutorial.

It has a lower CPU and Memory footprint than the Desktop version of Ubuntu.

Download ISO

Either go to www.ubuntu.com and select Ubuntu Server from the Download menu

And choose Option 3 - Manual install

or head straight to the download URL below.

Download Ubuntu Desktop | Download | Ubuntu
Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.

Click on the Green Download button and download the Ubuntu ISO file to your Downloads folder.

What is an ISO File?
An ISO file is basically the contents of a CD Rom in a single file. Its like a zip file built specfically to copy to a CDROM and they are used to emulate a CD Rom for Virtualbox

This should download a file named ubuntu-20.04.1-live.server.iso which at the time of writing was the latest version of Ubuntu server LTS (Long term support release)

Install Ubuntu

Once the Ubuntu ISO file has downloaded we are ready to continue.

This section is taken from

How to Install Ubuntu Server on VirtualBox
In this post I’ll show you how to install Ubuntu Server 18.04.3 on VirtualBox. I’ll also demonstrate how to connect to the Ubuntu instance via SSH.

I have edited and updated the text where needed for the purposes of this blog.

Create a New Virtual Machine

Start up VirtualBox. This should open the VirtualBox Manager, the interface from which you will administer all of your virtual machines.

Welcome to VirtualBox

Next Click on New (in the top right of the VirtualBox Manager), give your virtual machine a name and the two drop down menus should automatically update.

Name: Ubuntu
Type: Linux
Version: Ubuntu (64-bit)
Name and operating system

Click Next. The wizard will now ask you to select the amount of memory (RAM) in megabytes to be allocated to the virtual machine. choose 2GB (2048 megabytes).

Memory size

Click Next and you will be prompted to add a virtual hard disk to the new machine. Make sure that Create a virtual hard disk now is selected, then press Create.

Note: You are creating a virtual hard disk here, not adding a new disk to your computer, what actually happens is a file emulating a hard disk is created on your Windows PC
Hard disk

Now we need to choose the file type for the new virtual hard disk. Make sure that VDI (VirtualBox Disk Image) is checked and press Next.

Hard disk file type

On the next screen you will be asked whether the new virtual hard disk should grow as it is used (dynamically allocated) or if it should be created at its maximum size. Make sure that dynamically allocated is selected, then click Next.

Note: Creating a Dynamic Disk, when to create a virtual disk of 50Gb, it doesn't take up 50Gb of disk space on your Windows host. it only creates a file of the size it needs up to 50Gb. so if the Ubuntu install is 5Gb in size the file will only be 5Gb.
Storage on physical hard disk

Finally, select the size of the virtual hard disk in megabytes. The default size of 10GB should be plenty, but feel free to increase this as you see fit. Then click Create.

Set Disk size to 40Gb
File location and size

The hard disk should now be created and after a short while you should find yourself back in the VirtualBox Manager. You should be able to see your newly created virtual machine listed on the left.

We now need to change your network settings so your Ubuntu server can get its IP address from your home router

Click on the Settings button and go to Network

Select Bridged Adaptor from the Drop down and click on OK

If your Adaptor name is not enp3s0 thats ok..

Install Ubuntu Server in the Virtual Machine

Make sure your virtual machine is selected and press Start. VirtualBox Manager will ask you to select a virtual optical disk file or a physical optical drive to start the virtual machine from. Select the iso file you downloaded previously and press Start.

Select start-up disk

The Ubuntu installation process will now begin. It consists of thirteen steps and is quite painless.

The Welcome Screen

Here you should select your preferred language. I’m using English.

Select English - GB if available, English if not
The Welcome Screen

The Keyboard Configuration Screen

Here you should select a keyboard layout.

Select English - Gb
The Keyboard Configuration Screen

The Network Connections Screen

Here Ubuntu will attempt to configure the standard network interface. Normally you can just accept the default and select Done.

Note: Make a note of the IP Address we will need it later, where i use 10.10.100.10 in this blog, you should use the IP Address in the installer (10.0.2.15 below for example)
The Network Connections Screen

The Configure Proxy Screen

If your system requires a proxy to connect to the internet (mine doesn’t, yours won't either), enter its details in the next dialogue. Then select Done.

The Configure Proxy Screen

The Ubuntu Archive Mirror Screen

If you wish to use an alternative mirror for Ubuntu, you can enter the details here. Otherwise accept the default mirror by selecting Done.

In the UK this will say gb.archive.ubuntu.com
The Ubuntu Archive Mirror Screen

The Filesystem Setup Screen

The installer can guide you through partitioning an entire disk or, if you prefer, you can do it manually (I wouldn't suggest manually this). If you choose to partition an entire disk you will still have a chance to review and modify the results before Ubuntu is installed. I selected Use An Entire Disk.

I was then prompted to select my virtual machine’s hard disk as the disk to install to, before being shown a summary of what the installer would do. As this is a “destructive action”. I was asked to confirm my choice with Continue.

Because we setup a 40Gb disk the size below will not read 15.997Gb it will read a number closer to 40
The Filesystem Setup Screen

The Profile Setup Screen

Here you are required to enter:

  • Your (real) name
  • Your server’s name: ghost
  • Your username: Sysadmin
  • Password: PeanutMokneyCar

Fill these details out as you see fit However the above will track with this blog.

The Profile Setup Screen

The SSH Setup Screen

Here we have a chance to install the OpenSSH server package. We’ll need this to connect to the virtual machine via SSH later on, so ensure that you select it.

You also have the opportunity to import your SSH keys from GitHub or Launchpad. I selected No for this option.

The SSH Setup Screen

Here you can select from a list of popular snaps to install on your system. Snaps are self-contained software packages that work across a range of Linux distributions. I didn’t select any.

The Featured Server Snaps screen

And that’s it, the installation is complete. Ubuntu will ask you to remove the installation medium (which you can do via Devices > Optical Drives > Remove disk from virtual drive > Force unmount) and then reboot.

If this option is grayed out, you’re good to go. Just reboot.

ogin using the username and password we entered earlier enter the username and press Enter, Enter the password and press Enter.

username: sysadmin
password: PeanutMonkeyCar

You should now see a screen similar to this

‌   Write down the IPv4 Address as we will need it later.

For the purpose of this blog the EXAMPLE IP address is 10.10.100.10 your IP address WILL be different.

Note:
Working in the Virtualbox console is ok, but it doesn't support things like copy and paste and I find it very restrictive. We can use SSH to connect from your windows box to the Ubuntu server.

SSH to Ubuntu

Hang on, what is SSH?

Secure Shell (SSH) is a software standard to support encrypted data transfer between two computers. It can be used to support secure logins, file transfers or general purpose connects. Servers maintained by ITS require SSH-based connections in most cases.

Its a tool you can use to connect remotely from your Windows PC to the Virtualbox machine you've just created and you can copy pretend you're on the Ubuntu machine. for the sake of this blog it also means that you can copy and paste commands from this blog page to the Ubuntu machine using an SSH Client.

In the real world the SSH client would be connecting to machines on the other side of the world.

SSH Client - Putty

Download the putty installer for Windows from

Download PuTTY: latest release (0.74)

Download the 64-Bit MSI Installer

Open File Explorer (Windows 10) or Windows Explorer (Windows prior to 10). The Windows logo key + e shortcut works for Windows 10 and earlier versions. Navigate to the Downloads directory (or wherever you saved the installer) and double-click on the installer file name.

The installer starts, showing the Welcome to the PuTTY Setup Wizard screen. Click Next.

The installer next asks for the destination folder. Normally, it is fine to accept the default. Otherwise, enter your preferred destination folder. Click Next.

The installer next asks you which PuTTY features to install.

It is convenient to have a shortcut on your desktop. Change the Add shortcut to PuTTY on the Desktop from unavailable (red x) to Will be installed on local hard drive. Click Install. If you are prompted to run the PuTTY Installer, then allow it to run.

The installer will inform you when the install is complete. Click Finish.

If you created the PuTTY desktop shortcut during the installation, then you have the PuTTY icon on your desktop. Double click the PuTTY icon to start the PuTTY SSH client.

If you did not create the desktop shortcut or cannot find it, then select the Windows Start button located on the bottom left of your desktop. Scroll to menu item PuTTY or PuTTY (64-bit), then select PuTTY.

The PuTTY Configuration window will start. Enter the hostname or IP address of the remote host you want to connect in the “Host Name (or IP address)” field, then click Open.

HostName (or IP address): 10.10.100.10 
(This will be the IP you wrote down earlier, 10.10.100.10 is my example IP)
Port: 22

You are alerted the first time you connect to a remote host to inform you the host’s SSH key is not cached in your PuTTY registry. This is normal. Click Yes to save the remote host’s SSH key in your local PuTTY registry to proceed. If in the future you connect to the same remote host, then you should normally not see this alert.

A Black screen with a prompt which reads "login as" will appear

Enter your remote host username and password at the login as: and Password: prompts, respectively.

sysadmin
PeanutMonkeyCar

You are now logged into your server with SSH. You should see output like this:

The programs included with the Ubuntu/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. sysadmin@ghostcrm:~$

sysadmin@ubuntu:>

‌‌Congratulations you have installed Virtualbox, setup an Ubuntu server and connected it to SSH..

Update Ubuntu

Next you are going to enter your first linux command which will install updates on the Ubuntu Server.

You can copy and paste this command into your putty session

Note:
In linux commands are case dependent so Apt and apt are two different commands and only apt will be recognised.

‌                          sudo apt update && sudo apt upgrade -y

You will be asked for your password enter

‌                          PeanutMonkeyCar

There is a lot to unpack here

sudo - your normal user has very basic rights to do anything on the system which might cause a problem. typing sudo in front of a command runs it with higher privileges

apt update - Ubuntu gets its updates from the internet, apt update pulls down the latest information about package versions to your local machine so it knows which packages to update.

&& - There are actually two commands apt upgrade and apt update, the && basically says if the previous command completes correctly run the next command.

apt upgrade - apt upgrade pulls down the packages you need to upgrade on Ubuntu from the internet, and updates them locally on the server. It also will make sure that in updating it doesn't break other packages and/or over write any custom files

-y - The apt upgrade command will prompt you "do you want to continue yes or no" if you add a -y it won't prompt you and will confine the upgrade.

At this point we have a working updated Ubuntu server and are ready to install GhostCRM

Install Ghost CRM

Before we can install GhostCRM we need to install and setup a Webserver, a Database and a programming language. While this might sound daunting, its really just a case of copying some commands. I'll try and explain what is happening during this section.

Install Prerequisites

Install Nginx

Nginx is a webserver for Linux, its a pretty powerful beast however the Ghost setup will do the heavy lifting for us.

Nginx will be used as a reverse proxy for your Ghost application:

sudo apt install -y nginx

If you are prompted for your password enter

PeanutMonkeyCar

Install MySQL

Download and install MySQL:

While not overly complex to install and setup the MySQL (or MariaDB) Database has a couple of extra security steps which if followed should be quite simple.

 sudo apt install -y mysql-server

Run the mysql_secure_installation script to setup password for the MySQL root user:

sudo mysql_secure_installation

Ths script will ask a set of questions to secure your SQL server

Note
Enter current password for root (enter for none): - Press Enter as there is no root password by default
You already have a root password set, so you can safely answer 'n'. - We do want to set a root password (root is the super user) use the password
BatKittenBanana
Change the root password? [Y/n] Y Enter Root password Enter Root Password again

The full script which runs is designed to add some security to the Database and will look as follows (or close to)

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.


Enter current password for root (enter for none): 
OK, successfully used password, moving on...


Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.


You already have a root password set, so you can safely answer 'n'.


Change the root password? [Y/n] n
 ... skipping.


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.


Remove anonymous users? [Y/n] y
 ... Success!


 Normally, root should only be allowed to connect from 'localhost'.  This ensures that someone cannot guess at the root password from the network.


Disallow root login remotely? [Y/n] y
 ... Success!


By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.


Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!


 Reloading the privilege tables will ensure that all changes made so far
 will take effect immediately.


 Reload privilege tables now? [Y/n] y
  ... Success!


 Cleaning up...


 All done!  If you've completed all of the above steps, your MariaDB
 installation should now be secure.


 Thanks for using MariaDB!

We also need to make a change to a config file

Run

Note: Nano is a text editor, there are many different ones on Ubuntu, vi, vim, emacs which are all great editors, for this blog Nano is the easiest to navigate
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

and add the following to [mysqld]:

default-authentication-plugin=mysql_native_password
Press Ctrl and X to Exit
Select Yes when prompted to Save

Now these changes have been made we need to restart the "service", the service what controls the application and we use it to start, stop, restart or reload an application. Windows has the same thing its just a bit more hidden. By restarting the mysql services the changes above are all reloaded and working.

Restart MySQL:

sudo systemctl restart mysql.service

Install Node.js and npm

Ghost is built on Node.js and follows Node’s Long Term Support (LTS) plan. Ghost only supports LTS versions of Node.js.

Note:
Curl is an application which we can use to download things from the internet without needing to use a web browser
the | at the end of the command is a pipe, and its telling Linux, whatever happens with the curl command redirect the output to whatever is after the | symbol. In this case its Bash, a command prompt. So this command downloads something from the internet and runs it automatically.
We it is actually doing is installing another repository, a site on the internet with installer files on it which Ubuntu can download inad install using apt

Download and install recommended Node.js version which is 12.x (Node v12 Erbium LTS) at the time of this writing:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - 
sudo apt install -y nodejs

npm is a separate project from Node.js, and tends to update more frequently. As a result, even if you’ve just downloaded Node.js (and therefore npm), you’ll probably need to update your npm. Luckily, npm knows how to update itself! To update your npm, type this into your terminal:

sudo npm install -g npm@latest

Install GhostCRM

If you've got this far, well done, we have finally reached the bit where we install the Blog software onto the Ubuntu Box. The Ubuntu is installed, the dpendencies installed and we are ready to go.

Install Ghost-CLI

Ghost-CLI is a command line interface (CLI) tool that makes installing and updating Ghost easy.

Install Ghost-CLI:

sudo npm install -g ghost-cli@latest

Troubleshoot the system for any potential issues when installing or updating Ghost:

 ghost doctor install 
You will probably get this warning that you can ignore - "System checks failed with message: 'Linux version is not Ubuntu 16 or 18'‌‌Some features of Ghost-CLI may not work without additional configuration.‌‌For local installs we recommend using ghost install local instead.‌‌? Continue anyway? Yes"

Install Ghost

Create the document root directory:

sudo mkdir -p /var/www/ghost

Change ownership of the /var/www/ghost directory to the non-root user with sudo privileges that you created. In this example, `sysadmin:

sudo chown sysadmin:sysadmin /var/www/ghost 

Navigate to the Ghost root directory:

cd /var/www/ghost

Ensure that the directory is empty to avoid file conflicts:

ls -a 

Install Ghost in production mode:

ghost install 

Answer each question as prompted. For more information about each question, visit the Ghost documentation:

Note:
As this is an example of setting up a server i'm not going to setup the SSL option as this requires some additional setup
? Enter your blog URL: http://ghost
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: BatKittenBanana
? Enter your Ghost database name: ghostdb
? Do you wish to set up Nginx? yes
? Do you wish to set up SSL? no
? Do you wish to set up "ghost" mysql user? yes
? Do you wish to set up Systemd? yes
? Do you want to start Ghost? yes

After installation is complete, run ghost ls to view running Ghost processes:‌                  

ghost ls 

And your done Ghost is installed

Complete the Setup

To complete the setup process, navigate to the Ghost configuration page by appending /ghost to the end of your blog’s URL or IP. This example uses

https://10.10.100.10/ghost

You will see the welcome page to setup the Ghost admin account.

After going through the setup process of admin account, you will be able to see the admin dashboard.

Congratulations, now you have successfully setup the ghost blog locally! ✌️

Feel free to experiment it out as you like. Try publishing some dummy blog post:

And proceed to `http://10.10.100.10/ to view your blog posts. In case you haven’t notice, it is the same URL as admin page without the /ghost/.

Boom! The test blog post has been successfully added.

Start/Stop the ghost blog

To stop the Ghost blog server, simply head back to the terminal and execute

cd /var/www/ghost
ghost stop

Now the Ghost Blog is not available at the URL anymore. To start Ghost again next time, simply go to ~/Documents/ghost/ directory to start the local server.

cd /var/www/ghost
ghost stop

What to do if you make a mistake?

One of the joys of doing this using virtualbox to test how to get the system running is in the case you make a mistake or want to start again you can Delete the Ubuntu machine by right clicking on it and selecting Remove

Note:
If its greyed out, right click on the machine and choose stop

You will be asked how, and select Delete all files

Then just start again

Shutdown Ubuntu

You will not want to use the Ubuntu machine in Virtualbox all the time.

To shut it down from putty type

sudo shutdown -h now

this will tell Linux to halt all the services and shut down ubuntu.

To restart Ubuntu you can type

sudo reboot

Everything you have setup will restart post reboot.

References

How to Install Ubuntu Server on VirtualBox
In this post I’ll show you how to install Ubuntu Server 18.04.3 on VirtualBox. I’ll also demonstrate how to connect to the Ubuntu instance via SSH.
How to Install Ghost CMS on Ubuntu 20.04 LTS
Ghost is a very popular modern open source publishing platform that can be used as a headless Node.js CMS.
mysql_secure_installation
Improve the security of a MariaDB installation.
How to Install VirtualBox Extension Pack: Detailed Overview
Installing VirtualBox Extension Pack allows you to unlock advanced VirtualBox features. Read how to install VirtualBox Extension Pack on Mac and Windows.
Download Ubuntu Desktop | Download | Ubuntu
Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.
VirtualBox Network Settings: All You Need to Know
VMs running on VirtualBox can be connected to different networks. Learn in today’s blog post about VirtualBox network modes and how they can be configured.
How to Install PuTTY SSH for Windows - Information Technology Services
For security reasons, PuTTY has replaced the previously provided SSH Secure Shell for Windows as the supported method of remote access. PuTTY is a free… (READ MORE)
How To Install Ghost: Setup & Configuration - Open Source Publishing
All the tools you need to get started with Ghost 👉Self-hosted install & setup, local install guide for development, contribution guidelines & premium hosted services!
How to install and try Ghost Blog in your own computer
Choosing a suitable blogging platform can be daunting… How do we know if Ghost is a suitable blogging platform for us? The best way perhaps is to install Ghost Blog locally and try it out.

Share Tweet Send
0 Comments
Loading...