さくらVPS【CentOS8】Apache

さくらVPSでカスタムインストールしたCentOS8にApacheをインストール

さくらVPSでカスタムインストールしたCentOS8(以下、CentOS8Server)にApache(httpサーバー)をインストールしました。

◎firewallの設定(httpサーバーのポートの開放)

  • firewall-cmdでhttpサーバーのポート(http)を解放しました。

    # firewall-cmd --add-service=http
    success
    # firewall-cmd --list-all
    public (active)
    :
      services: cockpit dhcpv6-client ftp http ssh
    :
    
  • firewall-cmdで起動時にhttpサーバーのポート(http)を解放するように設定しました。

    # firewall-cmd --permanent --add-service=http
    success
    
  • 以下のコマンドでfirewalldサービスを再起動しました。
    # systemctl restart firewalld
    

◎Apache(2.4.37)のインストール

  • httpd-develとmod_sslをdnfコマンドでインストールしました。

    # dnf install httpd-devel mod_ssl
    :
    Installed:
      httpd-devel-2.4.37-12.module_el8.0.0+185+5908b0db.x86_64                                                
      mod_ssl-1:2.4.37-12.module_el8.0.0+185+5908b0db.x86_64                                                  
      apr-util-bdb-1.6.1-6.el8.x86_64                                                                         
      apr-util-openssl-1.6.1-6.el8.x86_64                                                                     
      apr-1.6.3-9.el8.x86_64                                                                                  
      apr-devel-1.6.3-9.el8.x86_64                                                                            
      apr-util-1.6.1-6.el8.x86_64                                                                             
      apr-util-devel-1.6.1-6.el8.x86_64                                                                       
      centos-logos-httpd-80.5-2.el8.noarch                                                                    
      httpd-2.4.37-12.module_el8.0.0+185+5908b0db.x86_64                                                      
      httpd-filesystem-2.4.37-12.module_el8.0.0+185+5908b0db.noarch                                           
      httpd-tools-2.4.37-12.module_el8.0.0+185+5908b0db.x86_64                                                
      libdb-devel-5.3.28-36.el8.x86_64                                                                        
      mod_http2-1.11.3-3.module_el8.0.0+185+5908b0db.x86_64                                                   
      sscg-2.3.3-6.el8.x86_64                                                                                 
      cyrus-sasl-2.1.27-0.3rc7.el8.x86_64                                                                     
      cyrus-sasl-devel-2.1.27-0.3rc7.el8.x86_64                                                               
      expat-devel-2.2.5-3.el8.x86_64                                                                          
      mailcap-2.1.48-3.el8.noarch                                                                             
      openldap-devel-2.4.46-9.el8.x86_64                                                                      
    
    Complete!
    
  • 以下のコマンドでサービスの自動起動を設定しました。
    # systemctl enable httpd
    
  • エディタ(nano)で「/etc/httpd/conf/httpd.conf」を編集しました。
    # cd /etc/httpd/conf/
    # cp httpd.conf httpd.conf.org
    # nano httpd.conf
    
    • <Directory /var/www/html>を下記のように変更しました。
      <Directory /var/www/html>
          #-# Options Indexes FollowSymLinks
          Options FollowSymLinks
          #-# AllowOverride None
          AllowOverride All
          Require all granted
      </Directory>
      
  • 「var/www/」と「var/www/html」のアクセス権を「755」、所有権を「apache」に変更しました。
    # chmod 755 /var/www/
    # chmod 755 /var/www/html
    # chown -R apache:apache /var/www/
    
  • systemctlコマンドでhttpdサービスを再起動しました。
    # systemctl restart httpd
    
  • Apacheのドキュメントルート「/var/www/html」に移動して、エディタ(nano)で「index.html」を作成しました。
    # cd /var/www/html
    # nano index.html
    
  • テスト用のHTMLファイル(test.html)は、以下のようなテキストファイルです。
    <html>
    <head>
    <title>Test</title>
    </head>
    <body>
    Test
    </body>
    </html>
    
  • 「index.html」の所有権を「apache」に変更しました。
    # chown apache:apache index.html
    
  • systemctlコマンドでhttpdサービスを起動しました。
    # systemctl start httpd
    
  • 念のためSELINUXが無効であることを確認しました。
    # getenforce
    Disabled
    
  • iMacのブラウザから「http://(CentOS8ServerのIP)/」にアクセスして、「index.html」の内容が表示されることを確認して、インストールを終了しました。
<= さくらVPS【CentOS8】FTP | | さくらVPS【CentOS8】MySQL =>
スポンサーリンク
ohhappyをフォローする
Sakura.Oh!Happy.JP