ghost-cli 는 ghost 를 관리할 수 있는 command line 유틸리티입니다.

옵션없이 ghost help 를 실행하면 전체 명령어를 볼 수 있습니다.

$ ghost help

host [command]

Commands:
  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 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)
BASH


명령어에 대한 자세한 용법을 보려면 COMMAND help 문법을 사용합니다. 다음은 ls 명령에 대한 설명을 표시합니다.

$ ghost ls help

ghost ls

View running ghost processes
BASH


시작/종료

start

고스트를 시작하려면 start 명령을 실행합니다.

ghost start
BASH

개발 환경으로 실행할 경우 -D 옵션을 주면 됩니다.

ghost start -D
BASH

또는 폴더에 config.production.json 가 없으면 자동으로 개발 모드로 실행합니다.

ls

전체 고스트 현황은 ls 명령으로 볼수 있습니다.

$ ghost ls

+ sudo systemctl is-active ghost_localhost
┌───────────┬───────────────────────────────────┬─────────┬──────────────────────┬────────────────────────┬──────┬─────────────────┐
│ Name      │ Location                          │ Version │ Status               │ URL                    │ Port │ Process Manager │
├───────────┼───────────────────────────────────┼─────────┼──────────────────────┼────────────────────────┼──────┼─────────────────┤
│ localhost │ ~/github/java-script/lesstif-blog │ 4.19.1  │ running (production) │ http://localhost:2368/ │ 2368 │ systemd         │
└───────────┴───────────────────────────────────┴─────────┴──────────────────────┴────────────────────────┴──────┴─────────────────┘

BASH

uninstall

ghost ls 로 보이는 instance 는 uninstall 명령으로 삭제할 수 있습니다. uninstall 은 고스트 설치 폴더로 가서 실행하면 되며 위 예제에서는 ~/github/java-script/lesstif-blog 입니다.

ghost uninstall
BASH


stop

인스턴스 종료는 stop 명령어를 사용합니다.

ghost stop
BASH

restart

설정을 변경했을 경우 stop/start 하지 말고 한 번에 restart 를 해주면 됩니다.

ghost restart
BASH

run

run 명령으로 고스트를 실행하면 백그라우드로 뜨지 않고 현재 터미널에 결과를 출력하므로 debugging 시에 유리합니다.

ghost run
BASH

config

현재 ghost 의 config 를 확인하고 설정할 수 있는 명령입니다.get

config 를 가져오려면 get 명령을 사용하며 뒤에는 가져올 key 를 입력합니다. 다음은 url 을 표시합니다.

$ ghost config get url
 
http://localhost:2369/
BASH

set

set key value 형식으로 config 를 설정할 수 있습니다.

다음은 url 을 localhost:2368 로 변경합니다.

$ ghost config set url http://localhost:2368

Successfully set 'url' to 'http://localhost:2368'
+ sudo systemctl is-active ghost_localhost
Ghost is running. Don't forget to run ghost restart to reload the config!
BASH


설정이 변경되었으면 안내 메시지대로 restart 를 해줍니다.

ghost restart
BASH


doctor

현재 시스템과 환경에 문제가 없는지 진단을 합니다. 

$ ghost doctor

✔ Checking system Node.js version - found v14.17.6
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
System checks failed with message: 'Missing package(s): nginx'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
BASH

setup

DB 연결 정보, URL 등을 바꿔야 할 경우 직접 설정 파일을 수정해도 되지만 setup 명령어로 단계별로 바꿀수 있습니다.

ghost 의 설정 파일은 운영 환경일 경우 config.production.json 로컬이나 개발 환경일 경우 config.development.json 에 저장됩니다.

setup 명령어로 이 파일을 다시 만들수 있으며 개발용 설정을 만들경우 -D, --development 옵션을 사용하면 됩니다.

$ ghost setup -D

? Enter your blog URL: http://localhost:2368
? Enter your MySQL hostname: localhost
? Enter your MySQL username: (ghost) 
BASH


setup 뒤에 특정 stage 를 명시할 수 있으며 stage 는 nginx, ssl, mysql, systemd, migrate, linux-user 중에 콤마를 구분자로 해서 하나 이상을 적어주면 됩니다.

다음은 개발 모드로 mysql 과 migrate 를 setup 합니다.

$ ghost setup mysql migrate -D 
BASH


설정이 완료되면 환경에 맞게 설정 파일(config.ENV.json) 에 반영되며 ENV 는 production 또는 development 입니다.


같이 보기

Ref