Choose a different version or distribution
Introduction
Before we begin talking about how to install Ghost on Ubuntu 20.04, let’s briefly understand – What is Ghost?
Ghost is a user-friendly open-source CMS for creating professional blogs and websites. With its user-friendly interface and streamlined features, Ghost empowers users to focus on writing and sharing their ideas effortlessly.
Whether you're a beginner or an experienced writer, Ghost empowers you to effortlessly write, publish, and optimize your web content. Discover the simplicity and power of Ghost CMS to bring your ideas to life and connect with your audience. Try Ghost today and elevate your online presence!
In this tutorial, you will install Ghost in an independent environment on Ubuntu 20.04. We will also address a few FAQs on how to install Ghost on Ubuntu 20.04.
Advantages of Ghost
- Simplicity: Ghost offers a minimalist and user-friendly interface, making it easy for both beginners and experienced users to create and manage professional-quality blogs and websites.
- Powerful Editor: Ghost's editor provides a distraction-free writing experience with markdown support, allowing writers to focus on their content creation process.
- Customizable Themes: With numerous customizable themes, Ghost allows users to personalize their blogs and websites to reflect their unique style and brand.
- SEO Friendly: Ghost is built with SEO optimization in mind, enabling users to easily optimize their content and improve their visibility in search engine results.
- Membership & Subscription Support: Ghost offers built-in membership and subscription features, allowing users to monetize their content, manage subscribers, and create exclusive content for their audience.
Prerequisites:
- We will use an Ubuntu20.04 VPS in this tutorial.
- Nginx Web Server
- Node.js LTS version
- Domain or Subdomain (for example, ghost.yourdomain.com) pointed to your server's IP address
- MySQL / MariaDB database server
- Ghost user (user with sudo privileges)
Step 1: Log in to the Server & Update the Server OS Packages
First, use SSH to connect to your Ubuntu 20.04 server as the root user.
ssh root@IP_ADDRESS -p PORT_NUMBER
Don't forget to substitute your server's real IP address and the SSH port number for IP_Address and Port_Number. If necessary, you should also change "root" to the admin account's username.
Run the instructions listed below once you are inside to update the package index and upgrade all installed packages to the most recent version.
sudo apt-get update && sudo apt-get upgrade
Step 2: Add Ghost user
Run the following commands to add a user with sudo
privileges for Ghost:
sudo adduser ghostuser
sudo adduser ghostuser sudo
Next, change to the ghost user.
su - ghostuser
Note: The Ghost-CLI and using the username ghost
conflict, thus you must choose another name.
Step 3: Install Nginx webserver
Use the following command to install the Nginx web server:
sudo apt-get install nginx
When the installation is finished, you may verify the Nginx service's status by:
sudo systemctl status nginx
You ought to see the following output:
Output
● 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 Thu 2021-12-23 09:22:55 UTC;
Docs: man:nginx(8)
Main PID: 3423 (nginx)
Tasks: 2 (limit: 2245)
Memory: 4.4M
CGroup: /system.slice/nginx.service
├─3423 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─3425 nginx: worker process
Step 4: Install MariaDB Server
To install the MariaDB server from the official Ubuntu repositories, enter the following command:
sudo apt-get install mariadb-server mariadb-client
The MariaDB server should launch automatically after installation.
The following command will allow you to check the MariaDB service's status:
sudo systemctl status mariadb
Output:
Output
● mariadb.service - MariaDB 10.3.32 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-12-23 09:28:03 UTC;
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 4489 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 2245)
Memory: 66.8M
CGroup: /system.slice/mariadb.service
└─4489 /usr/sbin/mysqld
Run the following command to make MariaDB ready to launch automatically whenever the server is restarted:
sudo systemctl enable mariadb
Then, use the following command to secure the MariaDB installation:
sudo mysql_secure_installation
As demonstrated below, this script will set the MariaDB root password, prevent remote root login, and eliminate anonymous users.
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Step 5: Create Ghost Database
Ghost stores its data in MySQL/MariaDB. Hence, you must create a user and database for Ghost.
First, use the command below to log into MariaDB:
sudo mysql -u root -p
Once logged in, execute the following command to establish a database and user:
MariaDB [(none)]> CREATE DATABASE ghostdb;
MariaDB [(none)]> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'securepassword';
Then, use the following command to allow full access to the Ghost database:
MariaDB [(none)]> GRANT ALL ON ghostdb.* TO 'ghostuser'@'localhost' WITH GRANT OPTION;
Then, use the following command to flush the privileges and log out of MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Step 6: Install Nodejs and NPM
Ghost was created with Node.js. Installing the LTS version of Node.js is a requirement for Ghost, and it does not support the non-LTS version.
Use the below command to add the Node.js repository:
sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
With the command below, install Node.js from the newly added repositories:
sudo apt-get install nodejs
The following command can be used to check the installed version of NodeJS after it has been set up:
node -v
You ought to see the following output:
v16.13.1
After Node.js is set up, use the following command to update NPM to the most recent version:
sudo npm install npm@latest -g
Now, use the command below to check the npm version:
npm -v
You ought to see the following output:
8.3.0
Step 7: Download and install Ghost
Use NPM to now install the Ghost-CLI
utility. It is a command-line interface (CLI) programme that enables simple Ghost installation and update with only one command.
sudo npm install ghost-cli@latest -g
Create a directory for Ghost in (/var/www/ghost/
).
sudo mkdir -p /var/www/ghost
In order to use the Ghost tool and download Ghost packages, you must first change the folder's ownership to your ghost user.
sudo chown ghostuser:ghostuser /var/www/ghost
sudo chmod 775 /var/www/ghost
Install Ghost after changing to the directory.
cd /var/www/ghost
To install Ghost, enter the following command:
ghost install
Ghost should start to change for packages that are necessary. Once everything has been verified, Ghost should start downloading the packages it needs to install.
✔ Checking system Node.js version - found v16.13.1
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
☱ Downloading and installing Ghost v4.32.0 > Installing dependencies >
Respond to each question as it is asked.
? Enter your blog URL: http://yourdomain.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghostdb
✔ Configuring Ghost
✔ Setting up instance
Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
? Do you wish to set up SSL? Yes
? Enter your email (For SSL Certificate)>[email protected]
? Do you wish to set up Systemd? Yes
? Do you want to start Ghost? Yes
Run ghost ls
after the installation is finished to see any active Ghost processes:
ghost ls
You ought to see the following output:
![Output](https://vegastack.com/tutorials/content/images/2023/03/image-445.png)
To finish the setup, open your browser and navigate to the Ghost admin interface:
https://yourdomain.com/ghost/
![Welcome Page](https://vegastack.com/tutorials/content/images/2023/03/image-446.png)
All done! The Ghost installation for Ubuntu 20.04 is complete.
FAQs to Install Ghost on Ubuntu 20.04
What are the hardware requirements for installing Ghost on Ubuntu 20.04?
Ghost requires a minimum of 1GB RAM, 1 CPU core, and 5GB of storage. However, depending on your traffic and usage, you may need to allocate more resources.
Can I use a different database other than the default SQLite?
Yes, Ghost supports MySQL and PostgreSQL databases. During the installation process, you can choose the database option that suits your needs.
How do I update Ghost to the latest version?
To update Ghost to the latest version, use the Ghost CLI tool. Run the command ghost update
in your terminal, and it will automatically install the latest version.
Can I use Ghost with an existing domain?
Yes, you can use Ghost with your existing domain. Simply configure your domain's DNS settings to point to the server running the Ghost instance.
Is it possible to have multiple Ghost installations on the same server?
Yes, you can install and run multiple Ghost instances on the same server using different ports or subdomains.
How can I secure my Ghost installation on Ubuntu 20.04?
Ensure your Ubuntu server has a firewall enabled, use HTTPS with an SSL certificate, keep your Ghost installation up-to-date, and regularly backup your data.
How can I configure email settings for Ghost?
During the installation process, Ghost-CLI will guide you through configuring email settings. You can set up an SMTP provider or use a custom email provider.
Conclusion
Installing Ghost on Ubuntu is a straightforward process using Ghost-CLI. By following the steps outlined in this tutorial and consulting the official Ghost documentation, you can set up your own blogging platform and start publishing your content with ease.
If you have any suggestions or queries, kindly leave them in the comments section.