とろんぽっと.nara の開発日記

留年しそうな情報系吹奏楽部高専生

Linux(CentOS 7)でWebサーバーの構築 ~Apache編~

httpd のインストール

[root@localhost ~]# yum -y install httpd

  # ウェルカムページを削除

[root@localhost ~]# rm -f /etc/httpd/conf.d/welcome.conf

 

httpd の設定 

例)   http://www.trompot.nara/ で80/TCPを使用する場合

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

   ServerAdmin root@trompot.nara       # 86行目:管理者アドレス指定

   ServerName www.trompot.nara:80   # 95行目:サーバー名指定

   AllowOverride All     # 151行目:変更

   DirectoryIndex index.html index.cgi index.php # 164行目:追記

# 以下を最終行に追記

   ServerTokens Prod # サーバーの応答ヘッダ
   KeepAlive On   # キープアライブオン
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd 

 

 ③ テストページ作成

[root@localhost ~]# vi /var/www/html/index.html
<!doctype html>

<html lang="ja">
<body>
<div style="width: 100%; font-size: 50px; font-weight: bold; text-align: center;">

テストページ index.html
</div>
</body>
</html> 

 

LAN上のデバイスからは「サーバー名」ではなく「サーバーのローカルIPアドレス」をでアクセスしてください。

 

以上です。

次回、SSLの導入を予定しております。