728x90
우분투에서 Ghost 블로그를 설치하는 방법
Ghost는 Node.js로 작성된 오픈 소스 블로그 플랫폼입니다. Nginx 및 MySQL과 함께 Ghost를 설치합니다.
전제 조건
공식적으로 권장되는 프로덕션 설치에는 다음 스택이 필요합니다.
- Ubuntu 20.04 또는 Ubuntu 22.04
- NGINX (SSL을 위한 최소 1.9.5)
- 지원되는 Node.js 버전
- MySQL 8
- Systemd
- 적어도 1GB 메모리가 있는 서버
- 등록된 도메인 이름
테스트 환경
- 운영체제 버전 정보
$ lsb_release -d
Description: Ubuntu 22.04.2 LTS
1. Nginx 설치 및 설정
sudo ln -s /etc/nginx/conf.d /etc/nginx/sites-available
sudo ln -sf /etc/nginx/sites-available /etc/nginx/sites-enabled
2. MySQL 설치 및 설정
mysql -uroot
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'caching_sha2_password' BY 'new_password';
FLUSH PRIVILEGES;
Ghost 데이터베이스 생성
CREATE DATABASE ghostdb;
CREATE USER 'ghostuser'@'127.0.0.1' IDENTIFIED BY 'ghost_password';
더보기
---
ALTER USER 'ghostuser'@'127.0.0.1' IDENTIFIED BY 'new_ghost_password';
---
GRANT ALL PRIVILEGES ON ghostdb.* TO 'ghostuser'@'127.0.0.1';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'ghostuser'@'127.0.0.1';
mysql> SHOW GRANTS FOR 'ghostuser'@'127.0.0.1';
+----------------------------------------------------------------+
| Grants for ghostuser@127.0.0.1 |
+----------------------------------------------------------------+
| GRANT USAGE ON *.* TO `ghostuser`@`127.0.0.1` |
| GRANT ALL PRIVILEGES ON `ghostdb`.* TO `ghostuser`@`127.0.0.1` |
+----------------------------------------------------------------+
2 rows in set (0.00 sec)
3. Node.js 설치
Ghost는 Node.js로 작동하므로 Node.js를 설치합니다. Node.js를 설치하려면 curl 명령어를 사용합니다.
Nodesource GPG 키 다운로드 및 가져오기
sudo apt-get update
sudo apt-get 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
deb 리포지토리 만들기
NODE_MAJOR=18
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
$ 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
deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main
업데이트 및 설치 실행
sudo apt-get update
sudo apt-get install -y nodejs
npm 및 nodejs 버전 정보 확인
$ npm --version
9.8.1
$ nodejs --version
v18.18.2
Ghost 사용자 생성
sudo adduser ghostuser
sudo usermod -aG sudo ghostuser
sudo echo 'ghostuser ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
su - ghostuser
Ghost-CLI 설치
sudo npm install ghost-cli@latest -g
$ sudo npm install ghost-cli@latest -g
added 599 packages in 57s
156 packages are looking for funding
run `npm fund` for details
npm notice
npm notice New major version of npm available! 9.8.1 -> 10.2.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.3
npm notice Run npm install -g npm@10.2.3 to update!
npm notice
$ which ghost
/usr/bin/ghost
$ ghost --version
Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org
Ghost-CLI version: 1.25.3
Ghost 사용법
더보기
---
$ ghost help
ghost [command]
Commands:
ghost backup Backup content & files
ghost buster Who ya gonna call? (Runs `yarn cache clean`)
ghost check-update Check if an update is available for a Ghost installation
ghost config [key] [value] View or edit Ghost configuration
ghost doctor [categories..] Check the system for any potential hiccups when installing/updating Ghost
ghost export file Export content from a blog
ghost import [file] Import a Ghost export
ghost install [version] Install a brand new instance of Ghost
ghost log [name] View the logs of a Ghost instance
ghost ls View running ghost processes
ghost migrate Run system migrations on a Ghost instance
ghost restart Restart the Ghost instance
ghost run Run a Ghost instance directly (used by process managers and for debugging)
ghost setup [stages..] Setup an installation of Ghost (after it is installed)
ghost start [name] Start an instance of Ghost
ghost stop [name] Stops an instance of Ghost
ghost uninstall Remove a Ghost instance and any related configuration files
ghost update [version] Update a Ghost instance
ghost version Prints out Ghost-CLI version (and Ghost version if one exists)
Global Options:
--help Show help [boolean]
-d, --dir Folder to run command in
-D, --development Run in development mode [boolean]
-V, --verbose Enable verbose output [boolean]
--prompt [--no-prompt] Allow/Disallow UI prompting [boolean] [default: true]
--color [--no-color] Allow/Disallow colorful logging [boolean] [default: true]
--auto Automatically run as much as possible [boolean] [default: false]
For more information, see our docs at https://ghost.org/docs/ghost-cli/
---
Ghost 디렉토리 생성
sudo mkdir -pv /var/www/ghost
sudo chown ghostuser.ghostuser /var/www/ghost
sudo chmod 755 /var/www/ghost
Ghost 설치
cd /var/www/ghost
ghost install
- Enter your blog URL: http://ghost.sangchul.kr
- Enter your MySQL hostname: localhost
- Enter your MySQL username: ghostuser
- Enter your MySQL password: [hidden]
- Enter your Ghost database name: ghost_prod
$ ghost install
...
✔ Checking system Node.js version - found v18.18.2
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
Downloading and installing Ghost v5.72.0
✔ Finishing install process
? Enter your blog URL: http://ghost.sangchul.kr
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod
...
Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/docs/config/#mail
------------------------------------------------------------------------------
Ghost was installed successfully! To complete setup of your publication, visit:
http://localhost:2368/ghost/
http://localhost:2368/ghost/
Ghost 환경 설정 파일(config.production.json)
vim config.production.json
{
"url": "http://ghost.sangchul.kr",
"server": {
"port": 2368,
"host": "127.0.0.1"
},
"database": {
"client": "mysql",
"connection": {
"host": "localhost",
"user": "ghostuser",
"password": "[hidden]",
"database": "ghostdb"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "systemd",
"paths": {
"contentPath": "/var/www/ghost/content"
}
}
Ghost 실행
ghost start
$ ghost start
Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org
+ sudo systemctl is-active ghost_ghost-scbyun-com
+ sudo systemctl reset-failed ghost_ghost-scbyun-com
Using https on all URLs is highly recommended. In production, SSL is required when using Stripe.
Support for non-https admin URLs in production mode is deprecated and will be removed in a future version.
✔ Checking system Node.js version - found v18.18.2
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_ghost-scbyun-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking systemd unit file
✔ Checking systemd node version - found v18.18.2
+ sudo systemctl start ghost_ghost-scbyun-com
+ sudo systemctl is-enabled ghost_ghost-scbyun-com
+ sudo systemctl enable ghost_ghost-scbyun-com --quiet
✔ Starting Ghost: ghost-scbyun-com
------------------------------------------------------------------------------
Your admin interface is located at:
http://ghost.sangchul.kr/ghost/
Ghost 서비스 재실행
sudo systemctl restart ghost_ghost-scbyun-com
systemctl status ghost_ghost-scbyun-com
Let's Encrypt SSL
Certbot 클라이언트 설치
sudo apt-get install -y certbot python3-certbot-nginx
Let's Encrypt SSL 인증서를 사용하도록 Nginx를 구성
sudo certbot --nginx -d ghost.sangchul.kr
$ sudo certbot --nginx -d ghost.sangchul.kr
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): postfix@gmail.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.
Requesting a certificate for ghost.sangchul.kr
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/ghost.sangchul.kr/fullchain.pem
Key is saved at: /etc/letsencrypt/live/ghost.sangchul.kr/privkey.pem
This certificate expires on 2024-02-02.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
Deploying certificate
Successfully deployed certificate for ghost.sangchul.kr to /etc/nginx/conf.d/ghost.sangchul.kr.conf
Congratulations! You have successfully enabled HTTPS on https://ghost.sangchul.kr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Nginx 구성
cat <<'EOF' > /etc/nginx/conf.d/ghost.sangchul.kr.conf
### nginx ghost.sangchul.kr.conf
server {
listen 80;
server_name ghost.sangchul.kr;
root /var/www/ghost;
index index.html index.htm;
access_log /var/log/nginx/ghost.sangchul.kr-access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location / {
proxy_pass http://127.0.0.1:2368; # Ghost 내부 서버 주소 및 포트
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ /.well-known {
allow all;
}
# deny access to .htaccess files, if Apache's document root concurs with nginx's one
#location ~ /\.ht {
# deny all;
#}
}
EOF
참고URL
- Ghost Developer docs : How to install Ghost on Ubuntu
- Ghost Developer docs : Ghost CLI
728x90
'리눅스' 카테고리의 다른 글
sshpass 명령어 (0) | 2023.11.06 |
---|---|
우분투에서 Ghost 블로그를 삭제하는 방법 (0) | 2023.11.04 |
우분투에서 pacemaker, corosync, pcs 패키지를 삭제하는 방법 (0) | 2023.11.03 |
우분투에서 VSFTPD를 설치하고 설정하는 방법 (0) | 2023.11.03 |
ipcalc 명령어 (0) | 2023.11.02 |