0
0

More than 1 year has passed since last update.

AWS EC2 AmazonLinux2にApacheを入れる

Last updated at Posted at 2022-03-08

概要

  • EC2のAmazonLinux2インスタンスにApacheを入れてApacheのテストページを表示する方法をまとめる。

方法

  1. EC2インスタンスにssh接続して下記コマンドを実行し、yumを最新の状態にする。

    $ sudo yum update
    
  2. 下記コマンドを実行してApacheをインストールする。

    $ sudo yum install httpd
    
  3. 下記コマンドを実行してApacheを起動する。

    $ sudo systemctl start httpd
    
  4. 下記コマンドを実行してApacheが正常に起動している事を確認する。

    $ systemctl status httpd.service
    Redirecting to /bin/systemctl status httpd.service
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/httpd.service.d
               └─php-fpm.conf
       Active: active (running) since 火 2022-03-08 08:18:05 UTC; 4s ago
         Docs: man:httpd.service(8)
     Main PID: 11711 (httpd)
       Status: "Processing requests..."
       CGroup: /system.slice/httpd.service
               ├─11711 /usr/sbin/httpd -DFOREGROUND
               ├─11712 /usr/sbin/httpd -DFOREGROUND
               ├─11713 /usr/sbin/httpd -DFOREGROUND
               ├─11714 /usr/sbin/httpd -DFOREGROUND
               ├─11715 /usr/sbin/httpd -DFOREGROUND
               └─11716 /usr/sbin/httpd -DFOREGROUND
    
     3月 08 08:18:05 ip-10-0-10-20.ap-northeast-1.compute.internal systemd[1]: Starting The Apache HTTP Server...
     3月 08 08:18:05 ip-10-0-10-20.ap-northeast-1.compute.internal systemd[1]: Started The Apache HTTP Server.
    
  5. 下記コマンドを実行して当該のEC2インスタンスが起動した時にApacheも起動する様に設定する。

    $ sudo systemctl enable httpd
    
  6. http://EC2インスタンスのパブリックIPアドレス にアクセスして下記のApacheのテストページが表示される事を確認する。

    Test_Page_for_the_Apache_HTTP_Server.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0