Installing Ghost on Ubuntu Linux with Nginx is a powerful way to set up a modern, fast, and customizable blogging platform. Ghost is known for its simplicity and speed, making it an excellent choice for personal bloggers, small businesses, or developers seeking a clean content management system. This step-by-step guide walks you through the entire process, from preparing your server to launching your Ghost blog. Before starting, ensure you have a fresh Ubuntu server (version 20.04 or newer) with root or sudo privileges. You will also need a domain name pointing to your server’s IP address, as well as basic familiarity with terminal commands. Let’s get started on creating a sleek, high-performance Ghost blog on your Ubuntu server with Nginx as your reverse proxy.
What You’ll Need
- An Ubuntu Linux server (20.04 or newer) with root or sudo access
- A registered domain name pointing to your server’s IP address
- Basic knowledge of Linux command line
- SSH client (like PuTTY or terminal)
- Optional: SSL certificate for HTTPS (we’ll cover obtaining one with Let’s Encrypt)
Step-by-Step
- Update your server and install necessary dependencies
Connect to your server via SSH and run:
sudo apt update && sudo apt upgrade -y
sudo apt install nginx nginx-full curl software-properties-common -yEnsure your system is up-to-date and Nginx is installed.
- Install Node.js (LTS version)
Ghost recommends Node.js v14.x or later. Use NodeSource to install:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejsVerify installation:
node -v
npm -v - Install Ghost-CLI
Ghost-CLI simplifies Ghost installation and management. Install globally with npm:
sudo npm install -g ghost-cli
- Create a directory for Ghost and set permissions
Choose a directory (e.g., /var/www/ghost), then create and set ownership:
sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost
cd /var/www/ghostEnsure your user has permissions to install and run Ghost here.
- Install Ghost
Run Ghost-CLI to install Ghost in the current directory:
ghost install
During installation, you’ll be prompted to set up your URL, email, and whether to configure SSL. Follow the prompts carefully. For example, input your domain name when asked for URL.
- Configure Nginx as a reverse proxy
Ghost installation with Ghost-CLI usually configures Nginx automatically. If not, create a new server block:
sudo nano /etc/nginx/sites-available/ghost
and add:
server {
listen 80;
server_name your.domain.com;
location / {
proxy_pass http://127.0.0.1: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;
}
}Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx - Secure your site with SSL
Use Certbot to obtain a free SSL certificate from Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your.domain.comFollow the prompts to set up HTTPS. Certbot will automatically update your Nginx configuration for SSL.
- Start Ghost and verify installation
Ensure Ghost is running:
ghost start
Visit your domain in a browser to see your Ghost blog live. You can also manage Ghost via Ghost-CLI commands like
ghost stop
and
ghost restart
.
Common Mistakes
- Not updating the server before starting, leading to dependency issues.
- Using incompatible Node.js versions; always use the recommended LTS.
- Misconfiguring Nginx or forgetting to enable the site, resulting in inaccessible site.
- Skipping SSL setup, leaving your site unencrypted.
- Not setting correct permissions for the Ghost directory, causing startup errors.
- Forgetting to restart services after configuration changes.
Tips
- Use a dedicated user account for running Ghost to enhance security.
- Regularly back up your Ghost content and database.
- Configure automatic renewal for your SSL certificates with Certbot:
sudo certbot renew --dry-run
- Monitor your server logs for errors, especially after updates or configuration changes.
- Secure your server with a firewall (e.g., UFW) and only open necessary ports.
Troubleshooting
If you encounter issues during installation or after, consider these steps:
- Ghost not starting: Check logs with
ghost logs
for errors. Ensure dependencies and permissions are correct.
- Nginx not serving your site: Verify your server block syntax with
sudo nginx -t
. Restart Nginx after changes.
- SSL not working: Confirm your SSL certificate is valid with
sudo certbot certificates
. Check Nginx SSL configuration.
- Domain not resolving: Use
ping your.domain.com
to verify DNS settings. Wait for DNS propagation if recently changed.
- Ghost installation incomplete or corrupted: Reinstall Ghost using
ghost install --force
.
Frequently Asked Questions
- Can I install Ghost without using Nginx?
- Yes, Ghost can run with other web servers like Apache or directly via its built-in server, but Nginx is recommended for performance and reverse proxy features.
- Is it necessary to use SSL for my Ghost blog?
- While not mandatory, SSL is strongly recommended to secure your site and protect visitor data. Let’s Encrypt makes it easy to obtain free certificates.
- Can I migrate my existing blog to Ghost?
- Migration depends on your current platform. You might need to export content and import it into Ghost using available tools or manual methods.
- How do I update Ghost to the latest version?
- Use the Ghost-CLI command
ghost update
in your Ghost directory to keep your installation current and secure.
- What should I do if Ghost crashes after an update?
- Check logs with
ghost logs
, ensure dependencies are compatible, and consider rolling back if necessary. Always back up before updates.
- Is there a way to run multiple Ghost sites on one server?
- Yes, by installing each Ghost instance in separate directories and configuring distinct Nginx server blocks for each domain or subdomain.
This comprehensive guide should help you successfully install and run Ghost on Ubuntu with Nginx, giving you a fast, reliable platform for your content. Remember to keep your system updated, secure, and backed up to enjoy a smooth blogging experience.
Related
- How to Hide Tabs in Chrome Windows 11 Easily in 2024
- How to Hide Specific Drives in Windows 11 for Privacy and Organization
- How to Hide Your Facebook Story from Someone Easily