VirtualBoxにいれたCentOS8にApacheをインストールしてみた。
今回はこちらのサイトを参考に、VirtualBoxにいれたCentOS8にApacheをインストールしてみました。この記事は実施内容の備忘録となります。
www.rem-system.com
- 1. 環境
- 2. httpdのインストール
- 3. httpdの起動
- 4. httpdの自動起動の設定
- 5. firewallに80番ポートの設定
- 6. httpd.confの編集
- 7. httpd.confのテストと設定の反映
- 8. 不要な設定ファイルのリネーム
- 9. テストページの確認
1. 環境
- Windows7 Home Premium
- VIrtualBox 5.2
- CentOS 8.0.1905
- Apache 2.4.37
2. httpdのインストール
まずはdnfコマンドを使用して下記4つのパッケージをインストールしていきます。
① httpd.x86_64 httpd ウェブサーバー本体
② httpd-devel.x86_64 httpd開発ツール、モジュールなど
③ httpd-manual.noarch httpdのマニュアル
④ httpd-tools.x86_64 httpdに関連するツール群
dnf -y install httpd httpd-tools httpd-devel httpd-manual
5. firewallに80番ポートの設定
80番ポートにアクセスできるよう、下記コマンドを実施します。
firewall-cmd --add-service=http --permanent
設定を反映するために、下記コマンドを実施します。
firewall-cmd --reload
6. httpd.confの編集
下記コマンドでhttpd.confを開き、編集していきます。
vi /etc/httpd/conf/httpd.conf
① ServerNameの設定
ServerNameのコメントアウトをはずし。名前を編集します。
② "/var/www/html"のOptionsの設定
OptiionsのIndexesを削除します。
7. httpd.confのテストと設定の反映
httpd.confの修正が完了したら、確認するコマンドがあるので確認していきます。
確認してOKでしたら、システムに反映します。
httpd -t systemctl restart httpd
8. 不要な設定ファイルのリネーム
不要な設定ファイルをリネームします。
mv autoindex.conf autoindex.conf.org mv welcome.conf welcome.conf.org
9. テストページの確認
/var/www/htmlに下記index.htmlを作成し、サーバーのIPもしくはlocalhostにブラウザでアクセスすると。。テストページが表示できました!
<html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Test Page </div> </body> </html>
以上、VirtualBoxにいれたCentOS8にApacheをインストールしてみた。でした。