웹사이트 검색

Ubuntu 18.04 LTS에 Cezerin 전자상거래 플랫폼을 설치하는 방법


이 페이지에서

  1. 요구 사항\n
  2. 시작하기\n
  3. Node.js 설치
  4. MongoDB 설치
  5. Cezerin 설치
  6. Nginx를 역방향 프록시로 구성\n
  7. Cezerin용 시스템 서비스 파일 생성
  8. 결론

Cezerin은 프로그레시브 웹 앱을 만드는 데 사용할 수 있는 무료 오픈 소스 React 및 Node.js 기반 전자 상거래 플랫폼입니다. SEO 친화적이고 서버 측 렌더링을 갖춘 단일 페이지 전자 상거래 애플리케이션입니다. 제품 범주, 재고 및 재고 관리, 파일 관리자, zip 아카이브로 테마 내보내기, zip 아카이브에서 테마 설치, 지불 게이트웨이, 암호 없음 등과 같은 많은 기능을 제공합니다.

이 튜토리얼에서는 Ubuntu 18.04 LTS에 Cezerin을 설치하는 방법을 설명합니다.

요구 사항

  • Ubuntu 18.04를 실행하는 서버.\n
  • 서버에 루트 암호가 설정되어 있습니다.\n
  • 고정 IP 주소 192.168.0.4가 서버에 구성되어 있습니다.

시작하기

먼저 최신 버전으로 서버를 업데이트해야 합니다. 다음 명령으로 수행할 수 있습니다.

apt-get update -y
apt-get upgrade -y

서버가 업데이트되면 다시 시작하여 모든 변경 사항을 적용합니다.

Node.js 설치

다음으로 최신 버전의 Node.js를 서버에 설치해야 합니다. 기본적으로 Node.js의 최신 버전은 Ubuntu 18.04 기본 리포지토리에서 사용할 수 없습니다. 따라서 시스템에 Node.js 저장소를 추가해야 합니다.

다음 명령을 사용하여 Node.js 리포지토리를 추가할 수 있습니다.

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

리포지토리가 추가되면 다음 명령을 사용하여 다른 필수 패키지와 함께 Node.js를 설치합니다.

apt-get install nodejs build-essential -y

다음으로 다음 명령을 사용하여 Node.js 버전을 확인합니다.

node -v

다음 출력이 표시되어야 합니다.

v12.5.0

다음 명령을 사용하여 NPM 버전을 확인합니다.

npm -v

다음 출력이 표시되어야 합니다.

6.9.0

완료되면 MongoDB 설치를 진행할 수 있습니다.

몽고DB 설치

기본적으로 MongoDB는 Ubuntu 18.04 기본 리포지토리에서 사용할 수 없습니다. 따라서 시스템에 MongoDB 리포지토리를 추가해야 합니다.

먼저 다음 명령을 사용하여 MongoDB GPG 키를 가져옵니다.

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

다음 출력이 표시되어야 합니다.

Executing: /tmp/apt-key-gpghome.noPsOh3sgA/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
gpg: key 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1

다음으로 다음 명령을 사용하여 MongoDB 리포지토리를 추가합니다.

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list

다음으로 다음 명령을 사용하여 리포지토리를 업데이트하고 MongoDB를 설치합니다.

apt-get update -y
apt-get install mongodb-org -y

MongoDB가 설치되면 다음 명령을 사용하여 MongoDB 서비스를 시작합니다.

service mongod start

다음 명령을 사용하여 MongoDB의 상태를 확인할 수도 있습니다.

service mongod status

다음 출력이 표시되어야 합니다.

? mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-07-03 08:57:58 UTC; 7s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 14712 (mongod)
   CGroup: /system.slice/mongod.service
           ??14712 /usr/bin/mongod --config /etc/mongod.conf

Jul 03 08:57:58 ubuntu1804 systemd[1]: Started MongoDB Database Server

완료되면 Cezerin 설치를 진행할 수 있습니다.

세제린 설치

먼저 Github 저장소에서 최신 버전의 Cezerin을 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.

cd /opt
git clone https://github.com/cezerin/cezerin.git

다음으로 디렉토리를 cezerin으로 변경하고 다음 명령을 사용하여 필요한 모든 종속성을 설치합니다.

cd /opt/cezerin
npm update node-sass
npm install --unsafe-perm --allow-root
npm run build
npm run setup

필요한 종속성이 모두 설치되면 다음 명령으로 서버를 시작합니다.

npm start

서버가 성공적으로 시작되면 다음 출력이 표시되어야 합니다.

>  start /opt/cezerin
> concurrently npm:start-*

[start-api] 
[start-api] >  start-api /opt/cezerin
[start-api] > node -r esm src/api/server/index.js
[start-api] 
[start-store] 
[start-store] >  start-store /opt/cezerin
[start-store] > node -r esm dist/store/server/index.js
[start-store] 
[start-api] info: API running at http://localhost:3001
[start-api] info: MongoDB connected successfully
[start-store] info: Store running at http://localhost:3000

이제 Cezerin이 설치되어 포트 3000에서 실행됩니다. 이제 웹 브라우저를 열고 URL http://192.168.0.4:3000을 입력하십시오. 다음 페이지와 같이 Cezerin 기본 대시보드로 리디렉션됩니다.

Nginx를 역방향 프록시로 구성

기본적으로 Cezerin은 포트 3000에서 실행됩니다. 따라서 포트 80을 사용하여 Cezerin에 액세스하려면 Nginx를 리버스 프록시로 구성해야 합니다.

이렇게 하려면 먼저 다음 명령을 사용하여 Nginx를 설치합니다.

apt-get install nginx -y

Nginx가 설치되면 다음 명령을 사용하여 Cezerin용 새 Nginx 가상 호스트 파일을 만듭니다.

nano /etc/nginx/sites-available/cezerin.conf

다음 줄을 추가합니다.

upstream cezerin {
  server 127.0.0.1:3000 weight=100 max_fails=5 fail_timeout=5;
}

server {
  listen          80;
  server_name     192.168.0.4;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://cezerin/;
  }
}

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 가상 호스트를 활성화합니다.

ln -s /etc/nginx/sites-available/cezerin.conf /etc/nginx/sites-enabled/

다음으로 다음 명령을 사용하여 구성 오류가 있는지 Nginx를 확인합니다.

nginx -t

모든 것이 정상이면 다음 출력이 표시됩니다.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

마지막으로 Nginx 서비스를 다시 시작하여 다음 명령으로 변경한 모든 사항을 적용합니다.

systemctl restart nginx

Cezerin용 Systemd 서비스 파일 생성

다음으로 Cezerin 서비스를 관리하기 위한 systemd 서비스 파일을 생성해야 합니다. 다음 명령으로 이 작업을 수행할 수 있습니다.

nano /etc/systemd/system/cezerin.service

다음 줄을 추가합니다.

[Unit]
Description=Cezerin Server

[Service]
ExecStart=/usr/bin/npm start
# Required on some systems
WorkingDirectory=/opt/cezerin
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example

[Install]
WantedBy=multi-user.target

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 구성 파일을 다시 로드합니다.

systemctl daemon-reload

다음으로 Cezerin 서비스를 시작하고 다음 명령을 사용하여 부팅 시 시작되도록 활성화합니다.

systemctl start cezerin
systemctl enable cezerin

다음 명령을 사용하여 Cezerin 서비스의 상태를 확인할 수도 있습니다.

systemctl status cezerin

다음 출력이 표시되어야 합니다.

? cezerin.service - Cezerin Server
   Loaded: loaded (/etc/systemd/system/cezerin.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-07-03 09:51:29 UTC; 11s ago
 Main PID: 18516 (npm)
    Tasks: 43 (limit: 1114)
   CGroup: /system.slice/cezerin.service
           ??18516 npm
           ??18538 sh -c concurrently npm:start-*
           ??18541 node /opt/cezerin/node_modules/.bin/concurrently npm:start-*
           ??18550 /bin/sh -c npm run start-api
           ??18551 npm
           ??18557 /bin/sh -c npm run start-store
           ??18559 npm

Jul 03 09:51:29 ubuntu1804 systemd[1]: Stopped Cezerin Server.
Jul 03 09:51:29 ubuntu1804 systemd[1]: Started Cezerin Server.
Jul 03 09:51:33 ubuntu1804 nodejs-example[18516]: >  start /opt/cezerin
Jul 03 09:51:33 ubuntu1804 nodejs-example[18516]: > concurrently npm:start-*

그게 다야! 이제 URL http://192.168.0.4를 사용하여 Cezerin 웹 인터페이스에 액세스할 수 있습니다.

결론

축하합니다! Ubuntu 18.04 서버에 Cezerin을 성공적으로 설치하고 구성했습니다. 이제 Cezerin을 사용하여 자신의 온라인 상점을 쉽게 호스팅할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.