LoginSignup
30
36

More than 5 years have passed since last update.

Apache2.4系をソースからインストール

Last updated at Posted at 2015-09-03

今回の投稿では、LAMP環境構築のためApache2.4系をソースからインストールする手順を説明していきたいと思います。1

1. 各種ツールの準備

今回、対象とするApache2.4系をソースからインストールするためには、APRとAPR-Util、PCREというものを事前にインストールする必要があります。
そこで、今回はこれらのツールもソースからインストールすることにしました。

2. APR(Apache Portable Runtime)のインストール

APRとは、OSとソフトウェアとの違いを吸収するソフトウェアというものらしいです。
インストールは、Download - The Apache Portable Runtime Project2のサイトからソースをダウンロードして行います。

# wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.5.2.tar.gz
# tar zxvf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/opt/apr-1.5.2
# make
# porg -lD "make install" # ※
# porg -a
apr-1.5.2

linuxでソースからインストールしたソフトウェアを管理の記事でインストールした porg を用いてインストールファイルを管理しています。

3. APR-Utilのインストール

同様にDownload - The Apache Portable Runtime Project2のサイトからAPR-Utilのソースをダウンロードしてインストールします。
このとき、 --with-apr オプションで先程インストールしたAPRのフォルダを指定します。

# wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.5.4.tar.gz
# tar zxvf apr-util-1.5.4.tar.gz
# cd apr-util-1.5.4
# ./configure --prefix=/opt/apr-util-1.5.4 --with-apr=/opt/apr-1.5.2
# make
# porg -lD "make install"
# porg -a
apr-1.5.2
apr-util-1.5.4
porg-0.8

4. PCRE(Perl Compatible Regular Expressions)のインストール

続いて、PCRE - Perl Compatible Regular Expressions3のページからPCREのソースをダウンロードしてインストールします。

# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
# tar zxvf pcre-8.39.tar.gz
# cd pcre-8.39
# ./configure --prefix=/opt/pcre-8.39
# make
# porg -lD "make install"
# porg -a
apr-1.5.2
apr-util-1.5.4
pcre-8.39

6. Apacheのインストール

Apacheのインストールを行います。今回は、Download - The Apache HTTP Server Project4のサイトにある最新のStableバージョンApache2.4.16をインストールします。
これまで同様にインストールしてきたAPRとAPR-Util、PCREのフォルダを --with-apr--with-apr-util--with-pcre で指定します。
また、SSLに対応をするため --enable-SSL--with-sslオプションも利用します。
※SSLのパスはOpenSSL バージョン1.0.2d をソースからインストール - Qiitaの記事でインストールしたOpenSSLのデフォルトのパス /usr/local/ssl に設定しています。

# wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//httpd/httpd-2.4.23.tar.gz
# tar httpd-2.4.23.tar.gz
# cd httpd-2.4.23
# ./configure --enable-ssl --enable-mods-shared=all --with-apr=/opt/apr-1.5.2 --with-apr-util=/opt/apr-util-1.5.4 --with-pcre=/opt/pcre-8.37 --with-ssl=/usr/local/ssl --enable-shared=ssl
# make
# porg -lD "make install"
# porg -a
apr-1.5.2
apr-util-1.5.4
httpd-2.4.23
pcre-8.37
# /usr/local/apache2/bin/httpd -v  # Apacheのバージョン確認コマンド
Server version: Apache/2.4.23 (Unix)
Server built:   Sep  9 2016 10:21:00

6. Apacheの起動

最後にApacheを起動して、「It works!」が表示されれば完了です。

# /usr/local/apache2/bin/apachectl start
# curl http://localhost/
<html><body><h1>It works!</h1></body></html>

参考文献

  1. Apache httpd 2.4 をソースからインストールする手順 (CentOS_RedHat) _ WEB ARCH LABO, http://weblabo.oscasierra.net/install-apache24-1/, Online; accessed 3–September–2015.
  2. Download - The Apache Portable Runtime Project, http://apr.apache.org/download.cgi, Online; accessed 3-September-2015.
  3. PCRE - Perl Compatible Regular Expressions, http://pcre.org/, Online; accessed 3-September-2015.
  4. Download - The Apache HTTP Server Project, http://httpd.apache.org/download.cgi#apache24, Online; accessed 3-September-2015.
30
36
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
30
36