Hosting your own blog can be hard, other alternatives like WordPress require hours of installation, theme compatibility checks, plugin troubleshooting and much more. Ghost includes everything you need to get up and running in just a few minutes!
More information about Ghost is available at https://ghost.org
- A VPS with Ubuntu 20.04
- A domain name
Step 1: Point your domain to your VPS IP address
These steps may vary for each domain registrar, this tutorial will explain how to point your domain to your VPS IP via CloudFlare.
- Navigate to CloudFlare.com and login
- Choose the domain you want to have your blog on
- Select “DNS” from the menu at the top of the screen
- Click “Add Record”
- Set “Type” to “A”
- Set “Name” to @ if you want it to be on your base domain (Eg. bmyblog.com) or the subdomain you want (Eg. blog)
- Set “IPv4 address” to the IP Address of your VPS
- Click “Save”
Step 2: Creating a new user
Ghost requires that a new user be created to install its software.
Run the following commands to create a new user, follow the on screen prompts:
You can choose any name for the new user here other than ghost as it causes issues with the Ghost installer, we will use blog in this example.
adduser blog usermod -aG sudo blog su - blog
Step 3: Installing NGINX
NGINX will be used as a reverse proxy to run your Ghost blog.
Run the following command to install NGINX and it’s dependencies:
sudo apt-get -y install nginx certbot python3-certbot-nginx
To verify that NGINX is installed on your machine, run the following command:
sudo systemctl status nginx
If you see an output similar to this, NGINX has been installed properly:
● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-05-26 08:18:56 CEST; 18s ago Docs: man:nginx(8) Main PID: 12200 (nginx) Tasks: 2 (limit: 2282) Memory: 6.6M CGroup: /system.slice/nginx.service ├─12200 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; └─12201 nginx: worker process
Step 4: Installing MySQL
Ghost needs a database to store all of your blog posts and accompanying data for your blog.
Run the following command to install MySQL:
sudo apt-get -y install mysql-server
You will need to set a password for your MySQL server, run the following commands to set a password:
Change password to a secure password and note it down as you will need it later on in this article.
If you created a user with a name other than blog, please substitute blog in the last command with the username you created.
sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; quit su - blog
Step 5: Install Node.js
Ghost uses the Node.js framework to run it’s software.
Run the following commands to install Node.js:
sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash sudo apt-get install -y nodejs
Step 6: Install Ghost-CLI
This will install Ghost’s command line interface for creating your blog.
Run the following command to install Ghost-CLI:
sudo npm install [email protected] -g
Step 7: Create the directories needed for your Ghost blog
Ghost requires directories to be made with the correct permissions for your blog to function properly.
Run the following commands to create the directories and add to the correct permissions:
If you created a user with a name other than blog, please substitute blog in the second command with the username you created.
sudo mkdir -p /var/www/ghost sudo chown blog:blog /var/www/ghost sudo chmod 775 /var/www/ghost cd /var/www/ghost
Step 8: Run the Ghost install process
This is the final step in getting your Ghost blog up and running!
Run the following command to begin your Ghost blog installation:
This installer is interactive and will ask you to enter configuration options, we will go over these below.
Throughout this process, you may be prompted multiple times for your sudo password, this is the password you set for your new user in Step 2.
Blog URL — This is the URL you set up in Step 1, enter it exactly including the protocol (Eg. https://myblog.com or https://blog.mysite.com).
MySQL hostname — This will tell Ghost where to connect to the database, since you installed the MySQL server locally, enter localhost.
MySQL username / password — This will tell Ghost how to authenticate with the MySQL database. Enter root for the username and for the password, enter the password you created earlier in Step 3.
Ghost database name — This is the database where Ghost will store all of the information for blog, you can set this to anything but we will be using the default of ghost_prod.
Set up a ghost MySQL user? — This will set up a user for your blog specifically for Ghost, this is recommended. Press enter to continue.
Set up NGINX? — NGINX is required to have your blog visible to the public. Press enter to continue.
Set up SSL? — SSL encrypts your website traffic and secures your blog, this is recommended. Press enter to continue, you will be required to enter your email to setup SSL.
Set up systemd? — Systemd will keep your Ghost blog running if a crash or reboot occurs, this is recommended. Press enter to continue.
Start Ghost? — This will start your Ghost blog. Press enter to continue. Once this completes, your Ghost blog should be live at the domain (Eg. https://myblog.com/admin) you setup in Step 1!