How To 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
orvim
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.
- Create a Non-Root User:
sudo adduser ghost_user sudo passwd ghost_user sudo usermod -aG wheel ghost_user
- Update the System:
sudo zypper update
- 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.
- 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
- Install Node.js and npm:
sudo zypper install nodejs npm
- Verify the Installation:
node -v npm -v
- 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.
- Install MariaDB:
sudo zypper install mariadb mariadb-client
- Start and Enable MariaDB:
sudo systemctl start mariadb sudo systemctl enable mariadb
- 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.
- 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.
- Install Ghost-CLI Globally:
sudo npm install -g ghost-cli@latest
- Verify the Installation:
ghost --version
- 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.
- Create a Directory for Ghost:
sudo mkdir -p /var/www/ghost
- Set Ownership:
sudo chown ghost_user:ghost_user /var/www/ghost
- Navigate to the Directory:
cd /var/www/ghost
- Install Ghost:
ghost install
- 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
- Blog URL:
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.
- 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.
- Location:
- Set Up the URL:Ensure the URL is correctly set to your domain.
- Configure the Server:Set the port (default is 2368) and bind to
127.0.0.1
for local access or0.0.0.0
for public access. - 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.
- 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
- Enable and Start the Ghost Service:
sudo systemctl daemon-reload sudo systemctl start ghost sudo systemctl enable ghost
- 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.
- Install Nginx:
sudo zypper install nginx
- 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; } }
- Test the Nginx Configuration:
sudo nginx -t
- Restart Nginx:
sudo systemctl restart nginx
- 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.
- Access the Ghost Admin Interface:Open
http://your_domain.com/ghost
in your web browser. - Create the Admin User:Follow the on-screen instructions to create your admin user.
- 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.
- Check the systemd logs:
- 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.
- Check the Nginx configuration for errors:
- Permission Errors:
- Ensure the
ghost_user
has the correct permissions to the Ghost directory. - Check file permissions and ownership.
- Ensure the
Keeping Ghost Updated
Keeping Ghost updated ensures you have the latest features and security patches. Use Ghost-CLI to update Ghost.
- Update Ghost:
ghost update
- Follow the Prompts:Follow the prompts to complete the update.
- 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.