openSUSE

How To Install Ghost on openSUSE

Install Ghost on openSUSE

Ghost is a powerful, open-source blogging platform designed for creating and managing online publications. It offers a clean, minimalist interface, making it an excellent choice for bloggers, journalists, and content creators. This guide walks you through the process of installing Ghost on openSUSE, providing step-by-step instructions to ensure a smooth setup. OpenSUSE, known for its stability and flexibility, provides a solid foundation for hosting Ghost, ensuring optimal performance and security. Whether you’re a seasoned developer or an enthusiastic blogger, this article will help you get Ghost up and running on your openSUSE server.

Prerequisites

Before diving into the installation, ensure your system meets the necessary prerequisites. These include both hardware and software requirements to guarantee a successful and efficient Ghost setup.

Hardware Requirements

  • Minimum RAM: At least 1 GB of RAM is recommended for running Ghost smoothly.
  • Storage Space: A minimum of 5 GB of free storage space is required for the Ghost installation and its data.
  • CPU: A dual-core processor is preferable to handle the workload efficiently.

Software Requirements

  • Operating System: openSUSE Leap 15.x or later is recommended for compatibility and stability.
  • Node.js and npm: Node.js is the JavaScript runtime that Ghost runs on, and npm (Node Package Manager) is used to install Ghost and its dependencies.
  • MySQL or MariaDB: A database server is needed to store Ghost’s data. MariaDB is a popular, open-source alternative to MySQL.
  • Text Editor: A text editor like nano or vim is essential for editing configuration files.

Initial Server Setup

Proper initial server setup is crucial for security and ease of management. Start by creating a non-root user with sudo privileges and ensuring your system is up to date.

  1. Create a Non-Root User:
    sudo adduser ghost_user
     sudo passwd ghost_user
     sudo usermod -aG wheel ghost_user
  2. Update the System:
    sudo zypper update
  3. Set Up a Firewall:
    sudo systemctl start firewalld
     sudo systemctl enable firewalld
     sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
     sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
     sudo firewall-cmd --reload

Installing Node.js and npm

Ghost requires Node.js to run. Follow these steps to install Node.js and npm on your openSUSE system.

  1. Add the Node.js Repository:Adding the official Node.js repository ensures you get the latest stable version.
    sudo zypper addrepo 'http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_Leap_15.4/nodejs.repo'
     sudo zypper refresh
  2. Install Node.js and npm:
    sudo zypper install nodejs npm
  3. Verify the Installation:
    node -v
     npm -v
  4. Update npm to the Latest Version:
    sudo npm install -g npm@latest

Setting Up the Database

Ghost supports MySQL and MariaDB. This guide uses MariaDB, a popular open-source database server. Follow these steps to install and configure MariaDB.

  1. Install MariaDB:
    sudo zypper install mariadb mariadb-client
  2. Start and Enable MariaDB:
    sudo systemctl start mariadb
     sudo systemctl enable mariadb
  3. Secure MariaDB:
    sudo mysql_secure_installation

    This script will guide you through setting a root password, removing anonymous users, disallowing remote root login, and removing the test database.

  4. Create a Ghost Database and User:
    sudo mysql -u root -p

    Enter your MariaDB root password when prompted.

    CREATE DATABASE ghost_db;
     CREATE USER 'ghost_user'@'localhost' IDENTIFIED BY 'your_password';
     GRANT ALL PRIVILEGES ON ghost_db.* TO 'ghost_user'@'localhost';
     FLUSH PRIVILEGES;
     exit;

    Replace 'your_password' with a strong, secure password.

Installing Ghost-CLI

Ghost-CLI is a command-line tool that simplifies the installation and management of Ghost. Install it globally using npm.

  1. Install Ghost-CLI Globally:
    sudo npm install -g ghost-cli@latest
  2. Verify the Installation:
    ghost --version
  3. Fix Potential Permission Issues:If you encounter permission issues, you may need to adjust permissions to allow Ghost-CLI to run without sudo.

Installing Ghost

With the prerequisites in place, you can now install Ghost. Follow these steps to install Ghost on your openSUSE server.

  1. Create a Directory for Ghost:
    sudo mkdir -p /var/www/ghost
  2. Set Ownership:
    sudo chown ghost_user:ghost_user /var/www/ghost
  3. Navigate to the Directory:
    cd /var/www/ghost
  4. Install Ghost:
    ghost install
  5. Answer the Installation Questions:Ghost-CLI will prompt you with several questions. Here are the recommended answers:
    • Blog URL: http://your_domain.com
    • MySQL hostname: localhost
    • MySQL username: ghost_user
    • MySQL password: your_password
    • Ghost database name: ghost_db
    • Set up a ghost user? (Y/n) – Type Y
    • Enter your email: your_email@example.com
    • Enter your blog title: Your Blog Title

Configuring Ghost

After installation, you can further configure Ghost by editing the config.production.json file. This file contains settings for the Ghost URL, server, database, and mail.

  1. Understand the config.production.json File:
    • Location: /var/www/ghost/config.production.json
    • Key Settings:
      • url: The URL of your blog.
      • server: Configuration for the Ghost server (e.g., port, host).
      • database: Database connection details.
      • mail: Mail configuration for transactional emails.
  2. Set Up the URL:Ensure the URL is correctly set to your domain.
  3. Configure the Server:Set the port (default is 2368) and bind to 127.0.0.1 for local access or 0.0.0.0 for public access.
  4. Configure Mail (Optional):Set up a mail provider (e.g., Mailgun, SendGrid) and add the necessary mail configuration to config.production.json.

Setting Up Systemd Service

To ensure Ghost runs reliably, set up a systemd service. This allows Ghost to start automatically on boot and restart if it crashes.

  1. Create a Ghost Systemd Service File:File location: /etc/systemd/system/ghost.service
    [Unit]
     Description=Ghost blog
     After=network.target mysql.service
     
     [Service]
     Type=simple
     WorkingDirectory=/var/www/ghost
     User=ghost_user
     Group=ghost_user
     ExecStart=/usr/bin/npm start --production
     Restart=always
     
     [Install]
     WantedBy=multi-user.target
  2. Enable and Start the Ghost Service:
    sudo systemctl daemon-reload
     sudo systemctl start ghost
     sudo systemctl enable ghost
  3. Check the Status of the Ghost Service:
    sudo systemctl status ghost

Setting Up Nginx as a Reverse Proxy

Nginx can be used as a reverse proxy to handle incoming traffic and forward it to the Ghost server. This improves performance and security.

  1. Install Nginx:
    sudo zypper install nginx
  2. Create an Nginx Configuration File for Ghost:File location: /etc/nginx/conf.d/ghost.conf
    server {
      listen 80;
      server_name your_domain.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;
      }
     }
  3. Test the Nginx Configuration:
    sudo nginx -t
  4. Restart Nginx:
    sudo systemctl restart nginx
  5. Enable HTTPS Using Let’s Encrypt (Optional):
    sudo zypper install certbot
     sudo certbot --nginx -d your_domain.com

    Certbot automatically configures Nginx to use HTTPS.

Finalizing Ghost Setup

Access the Ghost admin interface in your web browser to finalize the setup.

  1. Access the Ghost Admin Interface:Open http://your_domain.com/ghost in your web browser.Install Ghost on openSUSE
  2. Create the Admin User:Follow the on-screen instructions to create your admin user.
  3. Explore the Ghost Dashboard:Familiarize yourself with the Ghost dashboard and its features.

Troubleshooting Common Issues

Here are some common issues you might encounter and how to resolve them.

  • Ghost Won’t Start:
    • Check the systemd logs: journalctl -u ghost.service
    • Verify the Node.js and npm versions.
    • Ensure the database is running and accessible.
  • Nginx Reverse Proxy Issues:
    • Check the Nginx configuration for errors: sudo nginx -t
    • Ensure Nginx is running: sudo systemctl status nginx
    • Verify that the proxy_pass directive is correctly pointing to the Ghost server.
  • Permission Errors:
    • Ensure the ghost_user has the correct permissions to the Ghost directory.
    • Check file permissions and ownership.

Keeping Ghost Updated

Keeping Ghost updated ensures you have the latest features and security patches. Use Ghost-CLI to update Ghost.

  1. Update Ghost:
    ghost update
  2. Follow the Prompts:Follow the prompts to complete the update.
  3. Back Up Your Data:Back up your Ghost data before updating to prevent data loss.

Congratulations! You have successfully installed Ghost. Thanks for using this tutorial for installing Ghost Content Management System on openSUE 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