[GCP] GCE 구축(CentOS 7)~Apache 가져오기까지의 절차(WEB 서버)

개시하다


GCP에서 GCE(CentOS 7) 구축에서 아파치 가져오기까지의 프로세스를 출력하고 싶습니다.
Apache가 표시되는 페이지를 대상으로 합니다.

구성도



GCE(CentOS 7) 사양


항목
설정
VM 이름
web01
시리즈
E2
기계 유형
e2.small
OS
CentOS7
vCPU
2
메모리(GB)
2
디스크 부팅
20GB

전제 조건

  • 등록된 GCP의 무료 평가판
  • 학습용 VM 설정 전제
  • 작업흐름


    ① GCE 만들기
    ② 패키지 업데이트
    ③ 아파치 설치, 확인

    작업 단계


    ① GCE 만들기


    1. GCP의 포털 화면을 열고 "Compute Engine"→"VM 인스턴스"를 선택합니다.


    Google Cloud Platform

    2. VM 인스턴스 → 인스턴스 만들기 를 선택합니다.



    3. 새 VM 인스턴스의 화면에서 다음과 같이 설정합니다.


    항목
    설정
    이름:
    web01
    구역
    Asia-northeast1(도쿄)
    구역
    asia-northeast1-a
    시리즈
    E2
    기계 유형
    e2-small

    4. 시동판의 "변경"을 클릭합니다.



    5. 아래와 같이 입력하고 선택을 클릭합니다.




    6. HTTP 및 HTTPS 트래픽을 허용하고 [제작]을 클릭합니다.


    ※ 기타 설치는 기본적으로 문제 없음

    7. VM 인스턴스 목록에 VM이 생성되었는지 확인합니다.


    ]

    ② 패키지 업데이트


    1. 대상의 실례적인'SSH'부분을 클릭한다.



    2. 연결을 기다립니다.



    3. 연결하면 다음 화면이 표시됩니다.



    4. 소프트웨어 패키지의 업데이트를 실시한다.


    명령하다
    sudo yum -y update
    
    실행 예)
    실행 예
    [office365testac0402@web01 ~]$ sudo yum -y update
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    epel/x86_64/metalink                                                                        |  50 kB  00:00:00     
     * base: ftp.iij.ad.jp
     * epel: ftp.riken.jp
     * extras: ftp.iij.ad.jp
     * updates: ftp.iij.ad.jp
    base                                                                                        | 3.6 kB  00:00:00     
    epel                                                                                        | 4.7 kB  00:00:00     
    extras                                                                                      | 2.9 kB  00:00:00     
    google-cloud-sdk                                                                            | 1.4 kB  00:00:00     
    ~~~~~
    Updated:
      bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.5             device-mapper.x86_64 7:1.02.170-6.el7_9.5            
      device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5              firewalld.noarch 0:0.6.3-13.el7_9                    
      firewalld-filesystem.noarch 0:0.6.3-13.el7_9                glibc.x86_64 0:2.17-324.el7_9                        
      glibc-common.x86_64 0:2.17-324.el7_9                        google-cloud-sdk.x86_64 0:339.0.0-1                  
      google-osconfig-agent.x86_64 1:20210429.3-g1.el7            kernel-tools.x86_64 0:3.10.0-1160.25.1.el7           
      kernel-tools-libs.x86_64 0:3.10.0-1160.25.1.el7             nss.x86_64 0:3.53.1-7.el7_9                          
      nss-sysinit.x86_64 0:3.53.1-7.el7_9                         nss-tools.x86_64 0:3.53.1-7.el7_9                    
      openldap.x86_64 0:2.4.44-23.el7_9                           python-firewall.noarch 0:0.6.3-13.el7_9              
      python-perf.x86_64 0:3.10.0-1160.25.1.el7                  
    
    Complete!
    [office365testac0402@web01 ~]$ 
    

    ③ 아파치 설치, 확인


    터미널 화면에 들어간 상태에서 WordPress 가져오기 작업을 실시합니다.

    1. 루트 사용자에게 스위치를 건다.


    명령하다
    sudo -i
    
    실행 예)
    실행 예
    [office365testac0402@web01 ~]$ sudo -i
    [root@web01 ~]# 
    

    2. 시간을 일본 시간으로 변경한다.


    명령하다
    timedatectl set-timezone Asia/Tokyo
    taimedatectl status
    
    실행 예)
    실행 예
    [root@web01 ~]# timedatectl set-timezone Asia/Tokyo
    [root@web01 ~]# timedatectl status
          Local time: Wed 2021-05-05 16:27:11 JST
      Universal time: Wed 2021-05-05 07:27:11 UTC
            RTC time: Wed 2021-05-05 07:27:11
           Time zone: Asia/Tokyo (JST, +0900)
         NTP enabled: yes
    NTP synchronized: yes
     RTC in local TZ: no
          DST active: n/a
    [root@web01 ~]# 
    

    3. Apache를 설치합니다.

  • Apache 설치
  • 명령하다
    yum -y install httpd
    
    실행 예)
    실행 예
    [root@web01 ~]# yum -y install httpd
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: ftp.iij.ad.jp
     * epel: ftp.riken.jp
     * extras: ftp.iij.ad.jp
     * updates: ftp.iij.ad.jp
    Resolving Dependencies
    --> Running transaction check
    ~~~~~~~~~~
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : apr-1.4.8-7.el7.x86_64                                                                          1/5 
      Installing : apr-util-1.5.2-6.el7.x86_64                                                                     2/5 
      Installing : httpd-tools-2.4.6-97.el7.centos.x86_64                                                          3/5 
      Installing : mailcap-2.1.41-2.el7.noarch                                                                     4/5 
      Installing : httpd-2.4.6-97.el7.centos.x86_64                                                                5/5 
      Verifying  : httpd-2.4.6-97.el7.centos.x86_64                                                                1/5 
      Verifying  : apr-1.4.8-7.el7.x86_64                                                                          2/5 
      Verifying  : mailcap-2.1.41-2.el7.noarch                                                                     3/5 
      Verifying  : httpd-tools-2.4.6-97.el7.centos.x86_64                                                          4/5 
      Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                     5/5 
    
    Installed:
      httpd.x86_64 0:2.4.6-97.el7.centos                                                                               
    
    Dependency Installed:
      apr.x86_64 0:1.4.8-7.el7          apr-util.x86_64 0:1.5.2-6.el7     httpd-tools.x86_64 0:2.4.6-97.el7.centos    
      mailcap.noarch 0:2.1.41-2.el7    
    
    Complete!
    [root@web01 ~]# 
    
  • Apache 버전 확인
  • 명령하다
    httpd -v
    
    실행 예)
    실행 예
    [root@web01 ~]# httpd -v
    Server version: Apache/2.4.6 (CentOS)
    Server built:   Nov 16 2020 16:18:20
    [root@web01 ~]# 
    
    ※ 2021/05/05시 기준 2.46.
  • Apache 시작/자동 시작 설정
  • 명령하다
    systemctl start httpd
    systemctl enable httpd
    
    실행 예)
    실행 예
    [root@web01 ~]# systemctl start httpd
    [root@web01 ~]# systemctl enable httpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
    [root@web01 ~]# 
    
  • Apache 부팅 확인/자동 부팅 확인
  • 명령하다
    systemctl status httpd
    systemctl is-enabled httpd
    
    실행 예)
    실행 예
    [root@web01 ~]# systemctl status httpd
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2021-05-05 16:41:23 JST; 1min 7s ago
         Docs: man:httpd(8)
               man:apachectl(8)
     Main PID: 27717 (httpd)
       Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
       CGroup: /system.slice/httpd.service
               ├─27717 /usr/sbin/httpd -DFOREGROUND
               ├─27718 /usr/sbin/httpd -DFOREGROUND
               ├─27719 /usr/sbin/httpd -DFOREGROUND
               ├─27720 /usr/sbin/httpd -DFOREGROUND
               ├─27721 /usr/sbin/httpd -DFOREGROUND
               └─27722 /usr/sbin/httpd -DFOREGROUND
    
    May 05 16:41:23 web01 systemd[1]: Starting The Apache HTTP Server...
    May 05 16:41:23 web01 systemd[1]: Started The Apache HTTP Server.
    [root@web01 ~]# systemctl is-enabled httpd
    enabled
    [root@web01 ~]# 
    
  • WEB 페이지 표시 확인
  • 브라우저에서 GCE의 외부 IP 주소를 입력하여 Apache 화면이 표시되는지 확인합니다.


    최후


    저도 GCP 관련 제품을 열심히 수출하고 있습니다!

    좋은 웹페이지 즐겨찾기