おじさんエンジニアの日記

おじさんエンジニアがWeb関連の技術、ガンプラのことを書くブログ

【CentOS】Apache2.2系をインストール

Apache2.2系の環境構築をしたいと思います。

前提

こちらのページで環境設定がされている

Apacheのインストール

今回はyumでインストールします。

CentALTのリポジトリを追加

標準のリポジトリでインストールすると2.2.15がインストールされます。
ほかの脆弱性などもありますので、最新版をインストールします。

# vi /etc/yum.repos.d/centos.alt.ru.repo

以下を記述

[CentALT]
name=CentALT Packages for Enterprise Linux 6 - $basearch
baseurl=http://centos.alt.ru/repository/centos/6/$basearch/
enabled=0
gpgcheck=0

確認

どのバージョンをインストールされるか念のため確認します。

# yum list --enablerepo=CentALT | grep httpd | grep CentALT
httpd.x86_64                           2.2.27-1.el6                      CentALT
httpd-devel.x86_64                     2.2.27-1.el6                      CentALT
httpd-manual.x86_64                    2.2.27-1.el6                      CentALT
httpd-tools.x86_64                     2.2.27-1.el6                      CentALT
lighttpd.x86_64                        1.4.32-1.el6                      CentALT
lighttpd-fastcgi.x86_64                1.4.32-1.el6                      CentALT
lighttpd-mod_geoip.x86_64              1.4.32-1.el6                      CentALT
lighttpd-mod_mysql_vhost.x86_64        1.4.32-1.el6                      CentALT
php-eaccelerator-httpd.x86_64          1:1.0-0.9.git42067ac.el6          CentALT
thttpd.x86_64                          2:2.25b-1.el6                     CentALT

この記事を書いている時点で最新の2.2.27がインストールできることが確認出来ました。

インストール

インストールします。

yum -y install --enablerepo=CentALT httpd httpd-devel mod_ssl

自動起動設定 & 確認

自動起動の設定をします。

chkconfig --add httpd
chkconfig httpd on

設定できたか確認します。

chkconfig --list httpd

初期設定

なにもせずに起動をしようとすると以下のようにメッセージがでます。

httpd を起動中: httpd: apr_sockaddr_info_get() failed for XXXXXX
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

ServerNameが設定されてないよと怒られたので、設定をします。

# vi /etc/httpd/conf/httpd.conf

以下のように修正します。

#ServerName www.example.com:80
↓
ServerName [IPアドレス]:80

起動 & 確認

/etc/init.d/httpd start

起動後ブラウザで確認をします。

http://[IPアドレス]

以下の画面が表示されれば成功です。

f:id:kouji0607:20140428230715j:plain