터미널 접속하여 Ghost 설치

터미널 접속하여  Ghost 설치
Photo by Gabriel Heinzer / Unsplash

Local Ghost를  AWS로 이전 - 3편

Ghost 공식 개발 페이지를 참고로 AWS EC2인스턴스에 Ghost를 설치하겠다. https://ghost.org/docs/  > get started > ubuntu 로 접근하면 ubuntu에서 설치하는 방법에 대한 최신 가이드를 확인할 수 있다.

How to install & setup Ghost on Ubuntu 16.04, 18.04, 20.04 or 22.04
A full production install guide for how to install the Ghost professional publishing platform on a production server running Ubuntu 16.04, 18.04, 20.04 or 22.04.
  1. 새로 ghost user를 만들고 새 계정으로 접속.
sudo adduser newuser
sudo usermod -aG sudo newuser
su newuser

2. 최신으로 프로그램 갱신.

sudo apt-get update
sudo apt-get upgrade

3. http 접속을 위한 엔진스 설치.

sudo apt-get install nginx
sudo ufw allow 'Nginx Full'

4. DB 서버 설치.

sudo apt-get install mysql-server

5. node.js 설치.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash
sudo apt-get install -y nodejs

6. 드디어 ghost-cli 설치.

sudo npm install ghost-cli@latest -g

But, 아래처럼 npm 버전에 문제가 있는 경우 버전업.

sudo npm install -g npm@9.8.1

7. 원하는 위치에 ghost를 운영해보자.

sudo mkdir -p /var/www/newuser
sudo chown newuser:newuser /var/www/newuser
sudo chmod 775 /var/www/newuser
cd /var/www/newuser
ghost install

아래는 설치중 스샷이다.

But, t4에서 ghost를 설치하다보면  아래 스샷처럼 Command failed: yarn install –no-emoji –no-progress 어쩌구저쩌구 혹은 yarn global add node- gyp  하라고 하는 에러가 날 수 있다. 이는 node 16버전에서 발생될 수 있는 이슈로 18버전으로 업그레이드하면 해결된다.

sudo apt-get remove nodejs
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install gcc g++ make
sudo apt-get update && sudo apt-get install yarn
sudo apt-get install -y nodejs

But, Ghost was able to start, but errored during boot with: ER_ACCESS_DENIED_ERROR가 아래처럼 발생된다면 mysql에서 비번을 새로 설정해 줘야함

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
quit
ghost install or ghost setup
How to Fix “Ghost was able to start, but errored during boot with: ER_ACCESS_DENIED_ERROR: Access denied for user ‘root’@’localhost’”
In this tutorial you will learn how to fix the issue that prevents Ghost instance from starting correctly, this issue happens because Ghost is not able to connect to the database. To fix this issue you need to create a database and the user for the database then restart the

8. 설지가 완료되면 다음 항목을 추가로 물어볼 것이다. 우선  url과 hostname은 기본 값으로 진행할 것이므로 enter키로 넘어가자. 단, db 이름과 비번은 자신이 원하는 값으로 입력.

url: http://localhost:2368 
hostname: localhost
username: root
database name: newuser_prod

But, 502 Bad gateway 페이지가 나온다면 nginx를 재시작 해준다.

sudo service nginx restart
Server ) Nginx 502 Bad Gateway 에러 / nginx 설정 잘못함
전제 상황 Nginx 로 서브 도메인을 걸어줌 [ * ] 와일드 카드 ssl 인증서 발급 컨테이너로 proxy_pass 해줌 급한 사람을 위한 미리보기 버퍼 확장하기 proxy_pass 확인하기 dns cname/a 레코드 ip 주소 확인하기 nginx를 재시작 했는지? 기존 코드 server { root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name test2.servername.co.kr; location / { proxy_pass h…

But, 정상 domain주소를 바로 입력했는데 아래처럼 ssl 셋팅중 에러가 난다면, 도메인 업체 페이지로 가서 IP 연결을 확인해볼 것.

9. url등 설정값 변경 및 https 접속을 위한 ssl 설정

ghost config url https://blog.pih.kr
ghost restart
ghost setup nginx
ghost setup ssl
ghost restart

이제 위에 입력한 url로 접속해보면 결과를 확인할 수 있다.


참고

웹페이지가 정상적으로 표지되지 안는다면 nginx을 별도의 폴더에서 구동하여 http 접속에 이상이 없는지 확인해보자!
sudo wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
sudo apt update
How to Install NginX on EC2 Ubuntu Instance
Connect to the SSH of the EC2 instance and add the signing key of the repository to your EC2 instance and then install nginx. Read this guide for details.
[Ubuntu & Linux ] 우분투&리눅스 // Nginx 사용 명령어
Nginx란, Apache처럼 웹서버 환경을 만들어주는 소프트웨어입니다. 웹서버란, 웹서버란 전체 서버 아키텍처의 앞단에서 HTTP 요청에 따라서 그 요청을 넘기고 그에 해당하는 file 혹은 리소스를 넘겨주는 역할을 당담. Nginx 사용 명령어 // 설치 $ sudo apt-get install nginx // 버전확인 $ nginx -v // 시작 $ sudo service nginx start $ sudo systemctl start nginx $ sudo /etc/init.d/nginx start // 재시작 $ sudo…

DB 에 원격 접속을 위한 설정( DB와 웹서버가 원격으로 분리된 경우 참고)
How to Connect to MySQL on Amazon EC2 from a Remote Server | Saturn Cloud Blog
As a data scientist or software engineer you may need to connect to MySQL on Amazon EC2 from a remote server for various reasons Perhaps you have a separate server where you perform heavy analytics tasks or maybe you need to access data from MySQL on EC2 for a web application hosted elsewhere Whatev…

AWS EC2 인스턴스 상태가 자주 1/2 checks passed가 되면서 정지 해버림. 인스턴스를 reboot하거나 stop > start해줌. 이때 공개IP가 변경될 수 있으므로 putty, filezilla, workbench등에도 적용해줘야 함. AWS의 elestic IP를 설정해주면 IP가 변경되는 문제는 없어지므로 해당 내용 검색해보시길...
Ec2 1/2 checks passed
Since today i can’t access my instance, i tried stop and restart several times but the status is always : “1/2 checks passed” I tried to create a snapshot, detach and reattach new volume but the r…