UbuntuUbuntu Based

How To Install Ghost on Ubuntu 24.04 LTS

Install Ghost on Ubuntu 24.04 LTS

Ghost is a powerful, open-source content management system (CMS) designed for modern publishing. Known for its sleek interface and robust features, Ghost has become a popular choice for bloggers, journalists, and businesses looking to create and manage their online content efficiently. In this guide, we’ll walk you through the process of installing Ghost on Ubuntu 24.04, ensuring you have a solid foundation for your publishing endeavors.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything needed to set up Ghost successfully on your Ubuntu 24.04 server:

  • A server running Ubuntu 24.04 with root or sudo access
  • Minimum system requirements:
    • 1 GB RAM
    • 1 CPU core
    • 30 GB of storage space
  • A domain name pointed to your server’s IP address
  • Basic familiarity with command-line operations

While these are the minimum requirements, for optimal performance, consider allocating more resources, especially if you expect high traffic or plan to run multiple Ghost instances.

Step 1: Update Ubuntu Packages

Before installing any new software, it’s crucial to ensure your system is up-to-date. This step helps prevent compatibility issues and ensures you have the latest security patches.

sudo apt update
sudo apt upgrade -y

The -y flag automatically answers “yes” to any prompts, streamlining the upgrade process. Once completed, your system will be ready for the Ghost installation.

Step 2: Install Nginx Web Server

Ghost utilizes Nginx as a reverse proxy for optimal performance. Let’s install and configure Nginx:

sudo apt install nginx -y

After installation, we need to allow HTTP and HTTPS traffic through the firewall:

sudo ufw allow 'Nginx Full'

Verify that Nginx is running correctly:

sudo systemctl status nginx

You should see output indicating that Nginx is active and running. If not, you can start it manually:

sudo systemctl start nginx

Step 3: Install MySQL Database

Ghost requires a MySQL database to store its content and settings. Note that while MariaDB is similar, it’s not officially supported by Ghost, so we’ll stick with MySQL:

sudo apt install mysql-server -y

After installation, it’s important to secure your MySQL setup:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database. These steps enhance your database security.

Next, let’s create a dedicated MySQL user and database for Ghost:

sudo mysql

Once in the MySQL prompt, run the following commands:

CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your_strong_password';
CREATE DATABASE ghostdb;
GRANT ALL ON ghostdb.* TO 'ghostuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_strong_password’ with a secure password of your choice. Remember this password, as you’ll need it during the Ghost installation process.

Step 4: Install Node.js

Ghost is built on Node.js and requires the Long Term Support (LTS) version. To ensure we get the correct version, we’ll use the NodeSource repository:

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

Verify the installation by checking the Node.js and npm versions:

node -v
npm -v

You should see version numbers displayed for both. If not, try logging out and back in, or restarting your server.

Step 5: Install Ghost-CLI

Ghost-CLI is the official command-line tool for installing and managing Ghost. Install it globally using npm:

sudo npm install ghost-cli@latest -g

This tool simplifies the Ghost installation process and provides useful commands for managing your Ghost instance.

Step 6: Create Directory for Ghost

Now, let’s prepare a directory where Ghost will be installed:

sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost
sudo chmod 775 /var/www/ghost
cd /var/www/ghost

These commands create the directory, set the correct ownership, and adjust permissions to allow Ghost to function properly.

Step 7: Run Ghost Installation

We’re now ready to install Ghost. Run the following command:

ghost install

The installation process will prompt you for various details:

  • Blog URL: Enter your domain name (e.g., https://yourdomain.com)
  • MySQL hostname: Usually ‘localhost’
  • MySQL username: ‘ghostuser’ (or the username you created earlier)
  • MySQL password: The password you set for the Ghost MySQL user
  • Ghost database name: ‘ghostdb’ (or the name you chose)

Ghost-CLI will then check your system’s compatibility and proceed with the installation. You’ll be asked about setting up SSL, Nginx configuration, and systemd. For a production setup, it’s recommended to answer ‘yes’ to these prompts.

If you choose to set up SSL (recommended for production sites), you’ll need to provide an email address for Let’s Encrypt certificates.

The installation process may take several minutes. Once completed, Ghost should start automatically.

Step 8: Complete Setup and Start Publishing

With Ghost installed, it’s time to complete the setup and start creating content:

  1. Access your Ghost admin panel by navigating to https://yourdomain.com/ghost in your web browser.
  2. Create your admin account by providing your site title, name, email, and password.
  3. Explore the Ghost admin interface to customize your site’s design and settings.
  4. Start creating and publishing your content using Ghost’s intuitive editor.

Ghost offers a range of themes and integrations to enhance your site. Take some time to explore these options and tailor your Ghost installation to your specific needs.

Install Ghost on Ubuntu 24.04 LTS

Troubleshooting and Maintenance

Even with a smooth installation, you might encounter issues or need to perform regular maintenance. Here are some tips:

Viewing Logs

If you encounter any errors, check the Ghost logs:

sudo journalctl -u ghost_yourdomain.com

Restarting Ghost

After making configuration changes, you may need to restart Ghost:

sudo systemctl restart ghost_yourdomain.com

Updating Ghost

Keeping Ghost up-to-date is crucial for security and accessing new features. Use Ghost-CLI to update:

cd /var/www/ghost
ghost update

Backing Up Your Ghost Installation

Regular backups are essential. Ghost-CLI can help:

ghost backup

This command creates a backup of your Ghost content and database.

Monitoring Performance

Keep an eye on your server’s performance, especially as your site grows. Tools like htop can help monitor resource usage:

sudo apt install htop
htop

Congratulations! You have successfully installed Ghost. Thanks for using this tutorial for installing Ghost CMS on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Ghost website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button