Set up multiple Ghost blogs for $5 a month – Part 2

Second part of my tutorial on creating multiple ghost blogs on a single digital ocean droplet for only $5 per month.

So in Part 1 we covered setting up your brand spanking new Digital Ocean droplet and first Ghost blog.

In this part we will discuss adding more than one blog to the same server. Let’s jump in.

SSH

If you’re following on from Part 1 you can ignore this step.

Connect to your DO droplet using the console (Digital Ocean dashboard) and login using your new password.

New linux user

Ghost will not install if you are the root user, and for good reason too. So before we can create our next blog we need to create our very own user, with super user privileges, to do all the install stuff.

To create a new user type the following command into the droplet console

adduser mrghost

Creates a new user called mrghost

The first thing you’ll be asked for is a password for the user. Make this a secure password and store it somewhere safe, like 1Password.

You’ll then be asked to fill out some details, like name, but you can hit enter on these steps as they are not required.

User permissions

In order for that user to be able to install Ghost it will need super user permissions.

usermod -aG sudo mrghost

Sets the user mrghost as a super user

You can test whether the user has super user permissions by running a command.

su - mrghost

Login as mrghost

sudo ls -la /root

Outputs the permissions of the root folder, which only a super user can do

You’ll need to enter the password for mrghost. Once you’ve done that you will see all the files and folder in the root folder output along with their permissions.

The new user is setup and ready for use. Now lets go back to the root user by logging out of mrghost.

logout

Logs out the current user.

Create new blog directory

We need to create a new directory in the `www` to house your new blog.

cd /var/www

Change directory to /var/www

You’re now in the directory for `www`. If you run the command ls – which lists the content of the current directory – you’ll see a folder called `ghost`. This is the folder for the first blog you created.

So let’s create a new one. The naming convention we will use is your domain name.

Important: Make sure the domain name for the second blog is pointing to your server.

sudo mkdir portfolio.example.com

Create new directory called portfolio.example.com

Now give mrghost permission.

sudo shown mrghost:mrghost ./portfolio.example.com

And last change to the new directory so we can start running commands from there…

cd portfolio.example.com

Default MySQL passwords

Before we continue you will need your default MySQL password from the server. When setting up your droplet Digital Ocean stores this password in a file so you can save it later.

sudo cat /root/.digitalocean_password

This will spit out a password for root and a password for the ghost MySQL user. Save these to a password manager for later.

Create new MySQL user for future installs

For this new blog and all future blogs we will need a user we can use without worrying about messing up the user ghost created. This new user will be called casper.

sudo mysql

Enter MySQL

CREATE USER 'casper'@localhost IDENTIFIED WITH mysql_native_password BY 'YOUR_PASSWORD';

Create the new casper user.

Make sure the password you use is secure. And don’t forget it.

You can make sure it was added with the following command…

SELECT User FROM mysql.users;

Output all MySQL users

… and we’re done.

exit;

Exit MySQL

Now we have a new user setup for MySQL and we can start installing Ghost.

Installing Ghost

We’re going to start installing Ghost in that new folder you create earlier.

Because Ghost cannot be run as the root user we need to login as mrghost to install it.

su - mrghost

Login as mrghost

Make sure you’re in your new blog directory.

cd /var/www/portfolio.example.com

And then run the installer…

ghost install

During the install process ghost will ask you a bunch of questions that are almost the same as the first blog you created. Just select the defaults for almost everything.

Make sure during installation that you use the new casper MySQL credentials for MySQL steps.

You may be asked for the password for mrghost during setup.

After you’ve setup ghost will ask to start and when you select yes. It will fail!

Ghost failed to start

Ghost won’t be able to start because the casper user doesn’t have permission to edit the database ghost just created. Heres how we fix that.

sudo mysql

Then…

`GRANT ALL PRIVILEGES ON portfolio_example_com_prod.* TO 'casper'@'localhost';`

Then…

exit;

And we can try to run Ghost again.

ghost run

You’ll see the command line spit out some logs showing that it’s creating new tables in the database. That means it’s working. Once it’s settled you’ll be able to access your website by the domain name.

You’re all set. Now you can stop ghost from running and start it properly.

Press Control+C and type the following command…

ghost start

New blog complete

You’re all set and your new blog is online.

You can repeat this step to create as many blogs as you need. If you find them not performing as well as they could you should think about scaling your Digital Ocean droplet up.

I figured out how to do this using a bunch of different sources and articles on setting up Ghost blogs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.