banner



How To Set Up A Ghost Server

How to upgrade your Ghost weblog to the latest version without breaking anything - Part 2

Summary

In office ane of this serial of manufactures, we exported everything from our existing Ghost installation and (optionally) applied various fixes to that exported information. This time we're going to get everything installed by running a single control which will download and execute a script I've written to practise just that. There'southward as well a fairly lengthy explanation of what'south going on backside the scenes, but yous probably don't need to read that flake. If yous don't already accept a blog upwards and running and you desire to set i up from scratch, then you only need to read this article on its own.

  • Part i: Overview and information export/fix
  • Function 2: The best manner to install Ghost on your server [This article]
  • Part 3: Installing and upgrading using a temporary domain and final steps (sorting out redirects, migrating comments, fixing DNS entries, etc)
  • Bonus: How and why yous should change your blog URLs to dateless format

Groundwork

Last time, I gave an overview of what I was trying to achieve and it's definitely worth reading if yous're upgrading from an older version of Ghost.

Procedure

The first thing yous need to exercise is cull where you're going to host your blog. I am hosting this site on Ubuntu 18.04 LTS at UpCloud[*] (that'southward an chapter link; if you use it you'll be given $25 of costless credit in one case you lot peak up your account with $x and I will also receive some credit to help pay for my hosting). I have found UpCloud to be extremely good and you tin can run more than than one site quite easily in a VM costing $v so, if yous use my link, the first seven months will only cost y'all $x in total.

Some other pop host is Digital Ocean [*] (I use them for some of my other projects) and that link gives you $100 in credit to use over 60 days (and then, once you've spent $25, I go some coin).

I've tested this script successfully on both hosts using $5/month VMs. I besides tested it on a B1S Ubuntu VM on Microsoft Azure.

Not only that, yous could host information technology for free for a year on Azure. If y'all open a new Azure account, too every bit getting $200 to spend in your first 30 days, you lot also get 12 months free for certain services, including the B1S VM I used to examination this installation. Check information technology out at https://azure.microsoft.com/en-u.s.a./gratis/ (I guess I should probably cheque to come across if I can get an affiliate link there; if I do, I'll let you know).

Footstep 0: Create a DNS entry for your temporary migration URL

The aim here is that nosotros're going to install Ghost using a temporary URL, get everything upwards and running properly (whilst our existing site is however alive) and and so switch over once we're happy that everything is working okay.

Since my blog runs at tomssl.com, I created an A tape called blog.tomssl.com, pointing to the IP address of my UpCloud server. I didn't want to give information technology a totally random name every bit I wasn't sure if the Ghost installation might make some filename choices based on the name that would be difficult to modify afterward.

Once you've created your new DNS record, y'all should cheque that your Ubuntu server can resolve it past running a simple ping command. due east.g. ping weblog.tomssl.com (remember, you need to ping your temporary domain, not the last domain).

Footstep 1: Install Ghost on your new server

The official guide for installing Ghost on Ubuntu is pretty good and you should certainly consider reading it. Nevertheless, if you're coming from an ancient version of Ghost, or if you might be going to upgrade an older version later on (think, you can hands host more one site on your VM), you'll need to make a few changes.

I've written a script to exercise all of this. Once you've logged in to your new server, just run the post-obit command and follow the on-screen prompts:

Install Ghost on Ubuntu with a single command:

gyre -L -south https://tomssl.com/ghost-install.sh | sudo -East bash

Yous need the -L to tell gyre to follow redirects, as that URL is a arrow to a raw file in my GitHub business relationship. You lot can bank check that for yourself by running the gyre command without -50:

          $ curl -s https://tomssl.com/ghost-install.sh Found. Redirecting to https://raw.githubusercontent.com/TomChantler/Ghost-Install/chief/ghost-install.sh        

Here's what happened when I ran curl -50 -south https://tomssl.com/ghost-install.sh | sudo -E bash on a make new Ubuntu server in UpCloud[*]:

Installing Ghost on a brand new Ubuntu server
Installing Ghost on a make new Ubuntu server

Afterward you've done that, you only need to install your blog. The final screen of the install script actually tells you precisely what to do, so let's have a look at it:

Instructions show when installation of Ghost complete

NOTE: When testing on Azure and on Digital Ocean, I plant I had to set a password for the ghost user (which I didn't accept to do on UpCloud).
After installing Ghost with my script, I had to run this command earlier switching user and installing my blog (where ghostuser is the name you chose when running the script):

sudo passwd ghostuser

To install a new blog, just run:

          su - ghostuser cd /var/www/ghostblog ghost install        

If you're upgrading from Ghost v0.10, then you need to run ghost install --v1 instead, which volition install Ghost v1.26.2. And then you need to import your blog and then you can update information technology to the latest version. This is what I had to exercise, simply it's not exactly onerous.

Hither's an animated gif showing me installing a v1 blog.

Installing Ghost v1.26.2 so you can upgrade afterward

Stride two: Importing and upgrading your onetime blog

This will be covered more fully in the next article in the serial. In brief, now you tin login to your new blog and get to Settings → Labs → Import Content and upload the json file you exported and fixed in part 1 of this series. So yous can upload the images binder that you likewise prepared in the last article. It volition need to become in www/var/[YOURBLOG]/content/images.

Then you tin upgrade it to the latest version by going to the home directory for the blog /var/world wide web/[YOURBLOG] and running ghost update, like this:

Updating your Ghost weblog to the latest version

And that should exist it. If you don't want to know anything more nearly what y'all did and why, y'all can stop reading now.


You merely need to read this next bit if you want to know what'due south going on backside the scenes in the install script.

How to install manually

The rest of this article tells you what to do if yous want to install Ghost by manus. If you reckon that I might take written this side by side bit get-go and and then decided to write a script to automate it, then well done yous.

If y'all've run the single control above and installed Ghost and y'all really don't intendance about what it was doing, then y'all can stop reading. This isn't an explanation of precisely what the script is doing, either, because a lot of the stuff in the script is just me trying to make it prissy to use. I might explicate some of information technology some other time if anybody'due south interested.

Here is the stuff the script is doing behind the scenes.

Create a new user and assign their rights

I've included the three commands and all the output (including the fact that your prompt is going to change).

The procedure is, simply:

adduser ghostuser, which creates a user called ghostuser. Give the user a potent countersign, but you don't demand to put anything sensible for the user data.

usermod -aG sudo ghostuser, which adds the user to the sudoers group (i.due east. gives them admin rights).

su - ghostuser, which starts a login beat as ghostuser ( su means substitute user).

Here's the output. Find how the prompt has inverse at the end (and remember that the root user has # every bit a prompt, whereas other users have $).

          [email protected]:~# adduser ghostuser  Calculation user `ghostuser' ... Adding new group `ghostuser' (1001) ... Adding new user `ghostuser' (1001) with group `ghostuser' ... Creating domicile directory `/home/ghostuser' ... Copying files from `/etc/skel' ... Enter new UNIX password:  Retype new UNIX countersign:  passwd: password updated successfully Changing the user information for ghostuser Enter the new value, or press ENTER for the default         Full Proper noun []: Ghost User         Room Number []:          Work Phone []:          Domicile Phone []:          Other []:  Is the information correct? [Y/northward] Y [electronic mail protected]:~# usermod -aG sudo ghostuser # adds ghostuser to the sudoers group [electronic mail protected]:~# su - ghostuser # opens a last session as ghostuser To run a command as administrator (user "root"), use "sudo <control>". See "man sudo_root" for details.  [email protected]:~$                  

We can do the residuum of the installation every bit the newly-created ghostuser. You'll know this as the subsequent bash commands will start outset with $ prompts.

Update packages
          $ sudo apt-get update && sudo apt-get upgrade        
Install NGINX
          $ sudo apt-get install nginx        

Later on installing NGINX, y'all should install and configure ufw if you haven't done so already. Here are the commands yous'll need (don't forget to allow SSH connections, otherwise you lot'll be kicked out of your server and y'all won't be able to get dorsum in; delight don't ask me how I know this).

                      sudo apt install ufw  sudo ufw default deny incoming  sudo ufw default allow outgoing  sudo ufw let ssh  sudo ufw allow 'Nginx Full'  sudo ufw enable        

Now check the status of your firewall, like this:

          [electronic mail protected]:~$ sudo ufw status verbose Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), disabled (routed) New profiles: skip  To                           Action      From --                           ------      ---- 22/tcp                       Permit IN    Anywhere                   fourscore,443/tcp (Nginx Total)      ALLOW IN    Anywhere                   22/tcp (v6)                  Permit IN    Anywhere (v6)              lxxx,443/tcp (Nginx Full (v6)) Let IN    Anywhere (v6)               [electronic mail protected]:~$                  

If everything is installed, simply non enabled, y'all might see this:

          [email protected]:~$ sudo ufw status verbose Condition: inactive        

Whereupon you tin cheque to encounter which rules y'all've got in identify, similar this:

          [e-mail protected]:~$ sudo ufw show added Added user rules (see 'ufw status' for running firewall): ufw allow 22/tcp ufw let 'Nginx Total'                  

Before enabling the firewall by running sudo ufw enable every bit before.

Install MySQL

Next nosotros need to install MySQL and set a root password (then that nosotros can use it with the Ghost-CLI).

          $ sudo apt-get install mysql-server $ sudo mysql Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 806 Server version: five.7.30-0ubuntu0.eighteen.04.1 (Ubuntu)  Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.  Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.  Type 'help;' or '\h' for assist. Blazon '\c' to clear the current input argument.  mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'REDACTED'; Query OK, 0 rows afflicted (0.01 sec)  mysql> quit Bye $        

If you ever forget your MySQL password, it tin can be really tricky to reset information technology. I should probably write a brusque article about that and link it hither.

Install Node.js

The version of Node.js you're going to install depends on the version of your blog you lot're going to install initially. Basically, if you lot're upgrading from an earlier version than v1.0, y'all'll need to install Node.js 10. The instructions tell y'all to install Node.js v12, merely that won't allow y'all to upgrade an older web log.

          $ ringlet -sL https://deb.nodesource.com/setup_10.10 | sudo -E bash $ sudo apt-get install -y nodejs        
Install Ghost-CLI

Now we need to install the latest version of the Ghost-CLI.

          $ sudo npm install [email protected] -g        
Install Ghost

Now follow the rest of the installation guide, up as far as Install Ghost where it tells you to create a directory and then run ghost install.

Information technology volition brand your life easier if yous proper name your directory with a name based on your final url, non your temporary one. In my instance, this meant that I created a directory at /var/world wide web/tomssl. Since I had created a user chosen ghostuser (you are advised against calling your user ghost), that meant I did this:

            sudo mkdir -p /var/www/tomssl sudo chown ghostuser:ghostuser /var/www/tomssl sudo chmod 775 /var/www/tomssl cd /var/www/tomssl                      
Is your onetime installation earlier than v1.0?

At this signal, if you're running a version of ghost which is older than v1.0, y'all're going to accept to install v1.0 first, import your web log and then upgrade it (which is a simple process achieved with a single control, so don't worry).

If, like me, you're upgrading from a v0.x version, you lot need to install ghost like this:

          ghost install --v1        

If it's v1.0 or newer, just run:

          ghost install        
Import your data

Import your data. Copy your files. Set the permissions. Make sure it all looks reasonable.

Update Ghost to the latest version

It will prompt yous to view a test folio before migrating, just you don't really care about that as we have to do it anyway and it's only a examination version until we sort it out and put it alive.

          $ ghost update        
Optionally update Node.js to v12

Don't do this until you've updated your weblog to the latest version. After y'all update node, y'all accept to force Ghost to practise another update, fifty-fifty though the version will be the same, just in example any of the dependencies have changed.

Update your source list with the version of Node.js yous want to upgrade to and and then run the install command once again. It will install over the meridian of the old version.

          $ curl -sL https://deb.nodesource.com/setup_12.ten | sudo -East bash $ sudo apt-go install -y nodejs $ ghost update --force        
Conclusion

In this commodity we saw an like shooting fish in a barrel way to install Ghost on a new Ubuntu server, simply by running curl -L -southward https://tomssl.com/ghost-install.sh | sudo -E bash. We too (optionally) found out perhaps more than nosotros wanted to know about what that single command needed to do behind the scenes and why.

Next fourth dimension, nosotros'll import our former web log using a temporary domain and perform the concluding steps before going live (sorting out redirects, migrating comments, fixing DNS entries, etc).

How To Set Up A Ghost Server,

Source: https://tomssl.com/the-best-way-to-install-ghost-on-your-server/

Posted by: shafferobjecoung00.blogspot.com

0 Response to "How To Set Up A Ghost Server"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel