How to Install Ghost on Ubuntu Server Latest

In this tutorial, we will guide you through the installation of Ghost on Ubuntu Server latest. Ghost is a free and open-source blog publishing platform that makes it easy to publish beautiful content online.

Prerequisites

Step 1: Update System Packages

Before we begin, it's always a good idea to update the system packages to their latest version. Run the following command to update the system packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js

Ghost is built using Node.js so we need to first install Node.js on our server. We will use the Node.js version manager nvm to install Node.js.

To download and install nvm, run the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Now that nvm is installed, we can install the latest version of Node.js by running the following command:

nvm install node

Once the installation is complete, verify that Node.js has been installed correctly by running the following command:

node -v

Step 3: Install Nginx

Ghost uses Nginx as a reverse proxy server. Install Nginx by running the following command:

sudo apt install nginx -y

Step 4: Create a New User

It's always a good practice to create a new user to install and manage Ghost. Create a new user by running the following command:

sudo adduser ghost

Step 5: Install Ghost

Switch over to the user ghost to install Ghost.

sudo su - ghost

Now, we can install Ghost using the following command:

npm install ghost-cli@latest -g

Once Ghost has been installed, we can use it to install the latest version of Ghost by running the following command:

ghost install

During the installation, we will be prompted to answer a few questions about our environment, such as selecting a database, setting up a URL for our site, and configuring Nginx.

After answering all the questions, Ghost will be installed successfully.

Step 6: Configure Nginx

We need to configure Nginx to work as a reverse proxy server for Ghost. Create a new configuration file:

sudo nano /etc/nginx/sites-available/ghost

Add the following configuration to the file:

server {
   listen 80;
   server_name yourdomain.com;

   location / {
       proxy_pass http://localhost:2368;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
   }

   # Enabling SSL (Optional)
   # listen 443 ssl http2;
   # ssl_certificate /path/to/your/ssl.crt;
   # ssl_certificate_key /path/to/your/ssl.key;
   # ssl_protocols TLSv1.2 TLSv1.3;
}

Replace yourdomain.com with your actual domain name. Save and close the file.

To enable the site, create a symbolic link from the configuration file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/

Test the Nginx configuration:

sudo nginx -t

If the output doesn't show any error, restart Nginx:

sudo systemctl restart nginx

Step 7: Access Ghost

Open a web browser and navigate to yourdomain.com. You should see the Ghost homepage.

Congratulations! You have successfully installed Ghost on Ubuntu Server Latest.

Conclusion

In this tutorial, we have walked you through the step-by-step installation of Ghost on Ubuntu Server Latest. Now, you have a fully functional Ghost blog hosted on your own server.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!