Ghost安裝

Ghost安裝
Photo by Nadiia Ganzhyi / Unsplash

在Linode上安裝Self-hosted Ghost,作業系統是Debian 13

更新系統

sudo apt update
sudo apt upgrade -y

安裝 nginx

sudo apt install nginx -y

防火牆

sudo ufw allow 'Nginx Full'
sudo ufw reload

安裝 Node.js 22

sudo apt install -y ca-certificates curl gnupg

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |
sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

NODE_MAJOR=22

echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg]
https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" |
sudo tee /etc/apt/sources.list.d/nodesource.list

sudo apt update
sudo apt install nodejs -y

安裝 Ghost CLI

sudo npm install -g ghost-cli@latest

安裝 MySQL

sudo apt install mysql-server -y

安裝 MariaDB(如果無法安裝MySQL時)

sudo apt install mariadb-server -y

建立資料庫

sudo mysql

CREATE DATABASE ghost_prod;

CREATE USER 'ghostuser'@'localhost'
IDENTIFIED BY '你的強密碼';

GRANT ALL PRIVILEGES
ON ghost_prod.*
TO 'ghostuser'@'localhost';

FLUSH PRIVILEGES;
EXIT;

建立網站目錄

sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost

cd /var/www/ghost

ghost install

Nginx 反向代理配置

server {
    listen 80;
    listen [::]:80;	
    server_name andowson.com blog.andowson.com;
	
    location ^~ /.well-known/acme-challenge/ {
        root /var/www/html;
        default_type "text/plain";
        try_files $uri =404;
    }
    
    # favicon bypass
    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
	
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
    }
}
Ghost: Simplifying Self-Hosting
Ghost is a powerful, open-source platform designed for creating and managing professional-grade websites, blogs, and publications. Its focus on simplicity, speed, and elegant design makes it an excellent choice for developers, system administrators, and tech-savvy users who value complete control over their data and infrastructure. In this

參考網站