Hey there, fellow tech enthusiasts! If you're eager to get started with Ghost, the fantastic blogging platform, and you're running Ubuntu, you're in the right place. In this step-by-step guide, we'll walk you through the process of downloading and setting up Ghost on your Ubuntu server. Let's embark on this journey together!
Step 1: Preparing Your Ubuntu Server
Before we dive into Ghost, ensure your Ubuntu server is ready. Open your terminal and update your system while installing some necessary software. Copy and paste these commands:
sudo apt update
sudo apt upgrade
sudo apt install -y nginx mysql-server nodejs npm
Step 2: Installing Node.js and npm
Ghost relies on Node.js and npm. Let's get them installed with the help of Node Version Manager (nvm). Type in these commands:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install node
Step 3: Ghost-CLI Installation
Managing Ghost is a breeze with Ghost Command Line Interface (Ghost-CLI). Get it globally installed with this command:
sudo npm install -g ghost-cli
Step 4: Setting Up Your MySQL Database
Ghost uses MySQL as its trusty database. In this step, we'll create a MySQL database and user to make Ghost feel at home. Enter these commands:
sudo mysql
Inside the MySQL shell, execute the following SQL commands to create a database and user:
CREATE DATABASE ghost;
CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON ghost.* TO 'ghostuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Ghost Installation
Now, let's get Ghost up and running. Execute the following commands:
sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost
cd /var/www/ghost
ghost install
Follow the prompts in the Ghost installation wizard to configure your MySQL database and server settings.
Step 6: Nginx Configuration
To serve your Ghost blog using Nginx, create a configuration file and add the following lines (replace "your_domain.com" with your actual domain or IP address):
sudo nano /etc/nginx/sites-available/ghost
server {
listen 80;
server_name your_domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}
Save the file, create a symbolic link, and restart Nginx:
sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Step 7: Starting Ghost
Your Ghost blog is almost ready for action. To start Ghost, enter the following commands:
cd /var/www/ghost
ghost start
Voila! Your Ghost blog is now live on your Ubuntu server. Time to unleash your creativity and start publishing fantastic content for the world to see.
Frequently Asked Questions (FAQ) About Installing Ghost CMS on Ubuntu
What is Ghost CMS?
Ghost CMS is an open-source, headless content management system that is designed to be simple yet powerful, focusing on enabling creators to publish content online. It's known for its simplicity, speed, and SEO friendliness.
What are the prerequisites for installing Ghost CMS on Ubuntu?
You need:
- A server running Ubuntu (18.04 or later versions are commonly supported).
- Node.js (check Ghost's documentation for the version required).
- MySQL (or MariaDB) and knowledge to create a database and user.
- Nginx (used as a reverse proxy for Ghost).
- A non-root user with sudo privileges.
How do I install Node.js on Ubuntu?
You can install Node.js using a package manager. For example, using NodeSource:
curl -sL https://deb.nodesource.com/setup_[version].x | sudo -E bash - sudo apt-get install -y nodejs
Replace [version]
with the specific version number supported by Ghost.
How do I install Ghost-CLI?
Ghost-CLI is a command-line tool to help you install and manage Ghost. Install it using npm (Node.js package manager):
sudo npm install ghost-cli@latest -g
How can I install Ghost?
A: Navigate to the directory where you want Ghost installed, and use Ghost-CLI:
mkdir [your-folder-name] cd [your-folder-name] ghost install
Follow the prompts to complete the installation. Replace [your-folder-name]
with the desired directory name.
How do I configure MySQL for Ghost?
After installing MySQL, create a new database and user for Ghost:
CREATE DATABASE ghost_prod; CREATE USER 'ghost_user'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON ghost_prod.* TO 'ghost_user'@'localhost'; FLUSH PRIVILEGES;
Replace 'your_secure_password'
with a secure password.
How to configure Nginx for Ghost?
While ghost install
can automatically set up Nginx for you, manual setup might involve creating a new configuration file in /etc/nginx/sites-available/
and creating a symbolic link to /etc/nginx/sites-enabled/
. Ensure to configure the server
block to proxy requests to Ghost.
How do I start Ghost?
If you used ghost install
, Ghost should start automatically. Otherwise, you can navigate to the Ghost installation directory and use Ghost-CLI:
cd [your-folder-name] ghost start
How can I update Ghost?
Using Ghost-CLI makes updating straightforward:
cd [your-folder-name] ghost update
How can I create a backup of my Ghost site?
A: You may use Ghost-CLI to export content via:
ghost export
However, for a complete backup (including themes and uploaded images), manually copy the content
directory. Additionally, ensure to back up your MySQL database using a tool like mysqldump
.
How to solve permission issues when running Ghost-CLI commands?
Ensure you're not running commands as root
. Use ghost doctor
to identify and often fix permission issues.
What should I do if my Ghost site is down?
A: Navigate to the installation folder and use Ghost-CLI to check the status. Review logs and consider restarting Ghost:
cd [your-folder-name] ghost status ghost logghost restart
Ensure to verify and validate the instructions based on your specific Ubuntu and Ghost versions. For comprehensive and updated guides, always refer to Ghost's official documentation. If you need to get more organic traffic from Google you can visit ghost SEO guide to optimize your website.