SW/리눅스

Ubuntu 18.04 : Ghost를 설치하는 방법, 예제, 명령어

얇은생각 2020. 11. 26. 07:30
반응형

Ghost는 Node.js 플랫폼 위에 구축된 현대적인 소스 퍼블리싱 플랫폼입니다. 사용자 정의가 완벽하고 사용이 간편하여 거의 0에 가까운 학습 곡선으로 컨텐츠를 게시할 수 있습니다.

이 튜토리얼에서는 Nginx를 프록시로, 무료 Let's Encrypt SSL 인증서, Node.js의 최신 LTS 버전 및 MySQL/MariaDB를 데이터베이스 백엔드로 사용하여 Ubuntu 18.04 서버에 보안 Ghost 블로그를 배포하는 방법에 대해 설명합니다.

 

 

 

필수 구성 요소

이 튜토리얼을 따르기 위한 전제조건은 다음과 같습니다.

공식 고스트 시스템 요구 사항에 따라 최소 1G의 RAM이 필요합니다. RAM이 1GB 미만인 서버가 있는 경우 스왑 파일을 생성할 수 있습니다.

공용 서버 IP를 가리키는 도메인 이름입니다. 이 튜토리얼에서는 example.com을 사용할 것입니다.

Nginx는 Ubuntu 18.04에 Nginx를 설치하는 방법에 따라 설치됩니다.

Ubuntu 18.04에서 UFW로 방화벽을 설정하는 방법에 따라 구성된 방화벽입니다. 포트 80 및 443이 열려 있는지 확인하십시오.

이 튜토리얼을 계속하기 전에 sudo 권한을 가진 사용자로 로그인했는지 확인합니다.

 

 

 

Node.js 및 Yarn을 설치

Ghost에 권장되는 Node.js 버전은 v8 Carbon LTS입니다. NodeSource 저장소에서 Node.js를 설치합니다. 

다음 curl 명령을 사용하여 Node.js v8에 대한 NodeSource 저장소를 사용하도록 설정합니다.

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -

 

 

다음을 입력하여 Node.js를 설치합니다.

sudo apt install nodejs

 

 

기타 설치 방법은 Ubuntu 18.04에서 Node.js를 설치하는 방법을 확인합니다.

yarn을 설치하려면 먼저 다음 명령을 사용하여 시스템에서 yarn 저장소를 활성화합니다.

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

 

 

리포지토리가 활성화되면 다음을 사용하여 yarn을 설치합니다.

sudo apt update
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

 

 

 

MySQL 설치

Ghost는 MySQL , MariaDB 및 SQLite 데이터베이스를 지원합니다. 이 튜토리얼에서는 Ghost를 프로덕션 모드에서 실행할 때 권장되는 데이터베이스인 MySQL을 사용합니다. 

다음 명령을 사용하여 MySQL 패키지를 설치합니다.

sudo apt install mysql-server

 

 

Mysql_secure_installation 명령을 실행하여 MySQL 설치의 보안을 향상시킵니다.

sudo mysql_secure_installation

 

 

 

MySQL 사용자 암호의 강도를 테스트하는 데 사용되는 PASSWORDECT PUGING을 구성하라는 메시지가 표시됩니다. 암호 유효성 검사 정책에는 낮음, 중간 및 높음 세 가지 수준이 있습니다. 암호 유효성 검사 플러그인을 설정하지 않으려면 ENTER를 누릅니다.

다음 프롬프트에서 MySQL 루트 사용자의 암호를 설정하라는 메시지가 표시됩니다.

루트 암호를 설정하면 이 스크립트는 익명 사용자를 제거하고 로컬 시스템에 대한 루트 사용자 액세스를 제한하며 테스트 데이터베이스를 제거하라는 메시지도 표시합니다. 모든 질문에 Y(예)로 대답해야 합니다.

다음에는 인증 방법을 auth_socket에서 mysql_native_password로 변경해야 Ghost 설치 관리자가 MySQL 서버에 액세스할 수 있습니다. 이렇게 하려면 MySQL 서버에 루트 사용자로 로그인합니다.

sudo mysql

 

 

그리고 mysql_native_password 메서드를 사용할 때 MySQL 루트 사용자에게 암호를 설정하는 다음 쿼리를 실행합니다.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_pasword';
FLUSH PRIVILEGES;

 

 

강력한 암호로 매우_strong_pasword를 변경해야 합니다.

 

 

 

Ghost-CLI를 설치

정식 Ghost CLI 유틸리티를 사용하여 Ghost를 설치합니다. 이 유틸리티를 사용하면 단일 명령으로 Ghost를 설치하거나 업데이트할 수 있습니다.

Ghost CLI는 npm 패키지로 제공됩니다. 다음 명령은 Ubuntu 시스템에 Ghost CLI를 전체적으로 설치합니다.

sudo yarn global add ghost-cli

 

 

 

Ghost 설치 위치 생성

권장 설치 위치인 /var/www/host 디렉토리에 Ghost를 다운로드하여 설치합니다.

디렉토리 유형을 작성하려면 다음을 수행합니다.

sudo mkdir -p /var/www/ghost

 

 

디렉토리의 소유권을 사용자에게 변경합니다.

sudo chown $USER:$USER /var/www/ghost

 

 

$USER는 사용자 이름을 유지하는 환경 변수입니다.

올바른 디렉터리 권한을 설정합니다.

sudo chmod 775 /var/www/ghost

 

 

 

Ghost를 설치

Ghost CLI가 설치되어 있고 모든 필수 구성 요소가 완료되었으므로 설치부터 시작할 수 있습니다.

/var/www/ghost 디렉토리로 변경합니다.

cd /var/www/ghost

 

 

Ghost 설치를 시작하려면 Ghost 설치를 실행하여 Ghost를 설치 및 구성하고 Nginx를 역방향 프록시로 구성하고 SSL 인증서를 무료로 암호화하여 사이트를 보호합니다.

ghost install

 

✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
System checks failed with message: 'Linux version is not Ubuntu 16'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? (y/N) y

 

 

설치 관리자가 시스템을 확인하고 위와 같이 몇 가지 경고를 출력합니다.

계속하려면 y를 입력하면 설치 관리자가 Ghost를 다운로드하여 설치합니다.

ℹ Checking operating system compatibility [skipped]
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v1.24.9
✔ Finishing install process

 

 

그런 다음 블로그 URL과 MySQL 정보를 설정하라는 메시지가 표시됩니다. MySQL 설치 섹션에서 설정한 루트 사용자 이름과 암호를 제공하고 기본 데이터베이스 이름 ghost_prod를 사용합니다.

? Enter your blog URL: https://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod

 

 

설치 관리자가 ghost라는 시스템 사용자를 생성하고 Ghost MySQL 사용자를 만들 것인지 묻는 메시지가 나타나면 Yes를 입력합니다.

✔ Configuring Ghost
✔ Setting up instance
Running sudo command: chown -R ghost:ghost /var/www/ghost/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
✔ Setting up "ghost" mysql user

 

 

그런 다음 설치 관리자가 Nginx를 설정할지 여부를 묻습니다. Yes를 입력하여 확인합니다.

? Do you wish to set up Nginx? Yes
✔ Creating nginx config file at /var/www/ghost/system/files/example.com.conf
Running sudo command: ln -sf /var/www/ghost/system/files/example.com.conf /etc/nginx/sites-available/example.com.conf
Running sudo command: ln -sf /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf
Running sudo command: nginx -s reload
✔ Setting up Nginx

 

 

Nginx가 설치되면 설치 관리자가 SSL을 설정할지 묻는 메시지를 표시합니다. 예를 입력하여 확인하면 구성 마법사가 전자 메일 주소를 입력하라는 메시지를 표시한 다음 도메인에 대해 무료 Let's Encrypt SSL 인증서를 생성하고 Nginx를 구성합니다.

? Do you wish to set up SSL? Yes
? Enter your email (used for Let's Encrypt notifications) admin@example.com
Running sudo command: mkdir -p /etc/letsencrypt
Running sudo command: ./acme.sh --install --home /etc/letsencrypt
Running sudo command: /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain example.com --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail admin@example.com
Running sudo command: openssl dhparam -out /etc/nginx/snippets/dhparam.pem 2048
Running sudo command: mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf
✔ Creating ssl config file at /var/www/ghost/system/files/example.com-ssl.conf
Running sudo command: ln -sf /var/www/ghost/system/files/example.com-ssl.conf /etc/nginx/sites-available/example.com-ssl.conf
Running sudo command: ln -sf /etc/nginx/sites-available/example.com-ssl.conf /etc/nginx/sites-enabled/example.com-ssl.conf
Running sudo command: nginx -s reload
✔ Setting up SSL

 

 

그런 다음 systemd 서비스를 설정할지 묻는 메시지가 표시됩니다. Y를 입력하면 설치 관리자가 ghost_example-com이라는 새 systemd 서비스를 생성하고 부팅 시 시작할 수 있도록 설정합니다.

? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_example-com.service
Running sudo command: ln -sf /var/www/ghost/system/files/ghost_example-com.service /lib/systemd/system/ghost_example-com.service
Running sudo command: systemctl daemon-reload
✔ Setting up Systemd

 

 

마지막으로 설치 관리자가 데이터베이스를 설정하고 Ghost를 시작할지 묻는 메시지가 나타나면 Yes를 입력합니다.

Running sudo command: /var/www/ghost/current/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
✔ Running database migrations
? Do you want to start Ghost? Yes
Running sudo command: systemctl is-active ghost_example-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
Running sudo command: systemctl is-active ghost_example-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
Running sudo command: systemctl start ghost_example-com
✔ Starting Ghost
Running sudo command: systemctl is-enabled ghost_example-com
Running sudo command: systemctl enable ghost_example-com --quiet
✔ Starting Ghost
You can access your publication at https://example.com
Next, go to your admin interface at https://example.com/ghost/ to complete the setup of your publication

Ghost uses direct mail by default
To set up an alternative email method read our docs at https://docs.ghost.org/docs/mail-config

 

 

 

Ghost 설정을 완료

브라우저를 열고 https://example.com/ghost/의 Ghost 관리 인터페이스로 이동하면 다음 화면이 표시됩니다.  

 

Ubuntu 18.04 : Ghost를 설치하는 방법, 예제, 명령어 1

 

시작하려면 Create your account 버튼을 클릭합니다.

계정 만들기 화면으로 리디렉션됩니다. 여기서 블로그 제목과 계정 전체 이름, 이메일 주소 및 암호를 입력해야 합니다.

 

Ubuntu 18.04 : Ghost를 설치하는 방법, 예제, 명령어 2

 

세부사항을 입력하고 팀 초대 단추를 누릅니다.

 

Ubuntu 18.04 : Ghost를 설치하는 방법, 예제, 명령어 3

 

이 화면에서 공동작업자 전자 메일 주소를 입력하라는 메시지가 표시됩니다. 나중에 수행할 작업을 클릭하면 블로그로 이동! 링크를 클릭하면 Ghost 대시보드로 리디렉션됩니다.

 

Ubuntu 18.04 : Ghost를 설치하는 방법, 예제, 명령어 4

 

여기서 새 게시물을 만들고, 사용자를 추가하고, Ghost 구성을 변경할 수 있습니다.

반응형