4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CentOS7にapache2.4.46をソースからインストール

Last updated at Posted at 2020-09-01

修正履歴

  • 2024-12-10 Markdown記述修正

はじめに

CentOS7にapache2.4.46をソースからインストールした履歴です。
たまにはソースからインストールしてみよう思ってやってみました。

環境

# cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)

インストール

ソースをダウンロード

# cd /usr/local/src/
# curl -OL https://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.46.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   338  100   338    0     0    789      0 --:--:-- --:--:-- --:--:--   812
100 9143k  100 9143k    0     0  9108k      0  0:00:01  0:00:01 --:--:-- 50.1M

# ls
httpd-2.4.46.tar.gz

展開

# tar zxf httpd-2.4.46.tar.gz
# ls
httpd-2.4.46  httpd-2.4.46.tar.gz

configure実行

# cd httpd-2.4.46/
# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.

エラーになるのでとりあえず、ドキュメントを見ろと言われるのでドキュメントを見る

# ls
ABOUT_APACHE     ap.d          CHANGES         configure     httpd.dsp   InstallBin.dsp  LICENSE       NWGNUmakefile     ROADMAP  VERSIONING
acinclude.m4     build         CMakeLists.txt  configure.in  httpd.mak   LAYOUT          Makefile.in   os                server
Apache-apr2.dsw  BuildAll.dsp  config.layout   docs          httpd.spec  libhttpd.dep    Makefile.win  README            srclib
Apache.dsw       BuildBin.dsp  config.log      emacs-style   include     libhttpd.dsp    modules       README.cmake      support
apache_probes.d  buildconf     config.nice     httpd.dep     INSTALL     libhttpd.mak    NOTICE        README.platforms  test

READMEファイルを確認

# cat README
<~省略~>
  Installation
  ------------

  Please see the file called INSTALL.  Platform specific notes can be
  found in README.platforms.
<~省略~>

README.platformsを見ろという事かな?と思ってみてみる

# cat README.platforms

                          Apache HTTP Server

  Platform specific notes:
  ------------------------

================
  Darwin (OS X):
   Apache 2 relies heavily on the use of autoconf and libtool to
   provide a build environment.  Darwin provides these tools as part
   of the Developers Tools package. Under Darwin, however, GNUlibtool
   is installed as 'glibtool' to avoid conflicting with the Darwin
   'libtool' program.  Apache 2 knows about this so that's not a
   problem.

   As of OS X 10.2 (Jaguar), the bundled versions work perfectly. Partly
   this is due to the fact that /bin/sh is now 'bash' and not 'zsh' as
   well as the fact that the bundled versions are up-to-date:
   autoconf 2.52 and (g)libtool 1.4.2.

   You will note that GNU libtool should actually be installed as
   glibtool, to avoid conflict with a Darwin program of the same
   name.

   There have been some reports that autoconf 2.52 prevents Apache's
   build system from correctly handling passing multi-value envvars
   to the build system (eg: CFLAGS="-g -O3" ./configure),  causing
   errors.  Use of bash does not seem to help in this situation.  If
   this affects you, downgrading to autoconf 2.13 (which is installed
   on Darwin) will help.

   With Leopard (at least up to 10.5.2), when running configure
   you will likely see errors such as:

      rm: conftest.dSYM: is a directory

   This is a known issue and will be fixed in a later version of the
   autoconf suite. These errors can be safely ignored.

   For later versions of OS X, (10.8 and 10.9), be sure to have Xcode
   AND Xcode Command Line Tools installed. httpd will built both with
   gcc and clang.

==========
  FreeBSD:
   autoconf 2.52 creates scripts that are incompatible with the Posix
   shell implementation (/bin/sh) on FreeBSD.  Be sure to use v2.13
   of autoconf.

   Threaded MPMs are not supported on FreeBSD 4.x.  Current releases of
   FreeBSD 5.x (5.2 or later) support threaded MPMs correctly.  You must pass
   '--enable-threads=yes' to APR's configure in order to enable threads.
   Additionally, you must use libthr or libkse via libmap.conf as the default
   libc_r is still broken as of this writing.  Please consult the man page for
   libmap.conf for more details about configuring libthr or libkse.
================
  HP-UX:
   The dlopen() system call in HP-UX has problems when loading/unloading
   C++ modules. The problem can be resolved by using shl_load() instead
   of dlopen(). This is fixed in the Apache 2.0.44 release.
   To enable loading of C++ modules, the httpd binary has to be linked with
   the following libraries :

   HP-UX (11.0 / 11i):
      When using shl_load        : "cpprt0_stub.s -lcl"
      When using dlopen          : "cpprt0_stub.s -lcl -lCsup"

   HP-UX (11i version 1.5 and greater):
      When using dlopen/shl_load : "cpprt0_stub.s -lcl -lunwind"

   The cpprt0_stub.s can be downloaded from the web site :
      http://h21007.www2.hp.com/hpux-devtools/CXX/hpux-devtools.0107/0083.html

   Compile cpprt0_stub.s with the PIC option
     cc -c +z cpprt0_stub.s
       - OR -
     gcc -c -fPIC cpprt0_stub.s
================
  AIX, using the vendor C compiler with optimization:
    There is an issue with compiling server/core.c with optimization enabled
    which has been seen with C for AIX 5.0.2.3 and above.  (5.0.2.0, 5.0.2.1,
    and 5.0.2.2 have an additional problem with Apache 2.0.x, so either upgrade
    the compiler or don't use optimization in order to avoid it.)

    cc_r works fine with -O2 but xlc_r does not.  In order to use xlc_r with
    -O2, apply the patch at

    http://www.apache.org/dist/httpd/patches/apply_to_2.0.49/aix_xlc_optimization.patch

    (That patch works with many recent levels of Apache 2+.)

================
  Solaris:

    On Solaris, better performance may be achieved by using the Sun Studio
    compiler instead of gcc.  As of version 11, it is now free (registration
    required).  Download the compiler from:

    http://developers.sun.com/prodtech/cc/downloads/index.jsp

    If you use Sun Studio, the following compiler flags (CFLAGS) are
    recommended:

      -XO4 -xchip=generic

================
  Ubuntu:

    You will need to ensure that you have either libtool 1.5.6
    or 2.2.6b, or later. Expat 2.0.1 and PCRE 8.02 are also
    recommended to be installed. If building PCRE from source,
    you'll also need g++.

Linuxのこと書いてないなぁと思ったが、libtoolいれておけばいいのか?とインストール

# rpm -q libtool
package libtool is not installed

# yum install libtool
<~省略~>
Installed:
  libtool.x86_64 0:2.4.2-22.el7_3

Dependency Installed:
  autoconf.noarch 0:2.69-11.el7         automake.noarch 0:1.13.4-3.el7          cpp.x86_64 0:4.8.5-39.el7                      gcc.x86_64 0:4.8.5-39.el7
  glibc-devel.x86_64 0:2.17-307.el7.1   glibc-headers.x86_64 0:2.17-307.el7.1   kernel-headers.x86_64 0:3.10.0-1127.19.1.el7   libmpc.x86_64 0:1.0.1-3.el7
  m4.x86_64 0:1.4.16-10.el7             mpfr.x86_64 0:3.1.1-4.el7               perl-Test-Harness.noarch 0:3.28-3.el7          perl-Thread-Queue.noarch 0:3.02-2.el7

Dependency Updated:
  glibc.x86_64 0:2.17-307.el7.1                                                   glibc-common.x86_64 0:2.17-307.el7.1

再度configure

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.

同じ内容。APRインストールすればいいのかな?という事でパッケージ確認

# yum search apr
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
=========================================================================== N/S matched: apr ===========================================================================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
apr-util-devel.i686 : APR utility library development kit
apr-util-devel.x86_64 : APR utility library development kit
apr-util-ldap.x86_64 : APR utility library LDAP support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
apr-util-nss.x86_64 : APR utility library NSS crytpo support
apr-util-odbc.x86_64 : APR utility library ODBC DBD driver
apr-util-openssl.x86_64 : APR utility library OpenSSL crytpo support
apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
pcp-pmda-haproxy.x86_64 : Performance Co-Pilot (PCP) metrics for HAProxy
apr.i686 : Apache Portable Runtime library
apr.x86_64 : Apache Portable Runtime library
apr-util.i686 : Apache Portable Runtime Utility library
apr-util.x86_64 : Apache Portable Runtime Utility library
haproxy.x86_64 : TCP/HTTP proxy and load balancer for high availability environments

  Name and summary matches only, use "search all" for everything.

あるっぽい。たぶんdevelパッケージも必要だと思うのでインストール

# yum install  apr-devel
<~省略~>
Installed:
  apr-devel.x86_64 0:1.4.8-5.el7

Dependency Installed:
  apr.x86_64 0:1.4.8-5.el7

もう一回実施

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

少し進んだ。APR-util が必要という事で入れる

# yum -y install apr-util
<~省略~>
Installed:
  apr-util.x86_64 0:1.5.2-6.el7

Complete!

また試す

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

かわらず。やっぱりdevelパッケージも必要なんだろうな。っと思ってインストール

# yum install apr-util-devel
<~省略~>
Installed:
  apr-util-devel.x86_64 0:1.5.2-6.el7

Dependency Installed:
  cyrus-sasl.x86_64 0:2.1.26-23.el7           cyrus-sasl-devel.x86_64 0:2.1.26-23.el7     expat-devel.x86_64 0:2.1.0-11.el7     libdb-devel.x86_64 0:5.3.21-25.el7
  openldap-devel.x86_64 0:2.4.44-21.el7_6

Dependency Updated:
  expat.x86_64 0:2.1.0-11.el7

Complete!

懲りずに再度実施

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

少し進んだがlibpcreがないといわれる

# yum search libpcre
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
=========================================================================== Matched: libpcre ===========================================================================
pcre.i686 : Perl-compatible regular expression library
pcre.x86_64 : Perl-compatible regular expression library
pcre2.i686 : Perl-compatible regular expression library
pcre2.x86_64 : Perl-compatible regular expression library

Error: Nothing to do

pcreというパッケージあるみたいなのでインストール

# yum install pcre
<~省略~>
Installed:
  pcre2.x86_64 0:10.23-2.el7

Complete!

また試す。

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

同じところでエラーになる。pcreパッケージを確認

# yum search pcre
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
========================================================================== N/S matched: pcre ===========================================================================
pcre-devel.i686 : Development files for pcre
pcre-devel.x86_64 : Development files for pcre
pcre-static.i686 : Static library for pcre
pcre-static.x86_64 : Static library for pcre
pcre-tools.x86_64 : Auxiliary utilities for pcre
pcre2-devel.i686 : Development files for pcre2
pcre2-devel.x86_64 : Development files for pcre2
pcre2-static.i686 : Static library for pcre2
pcre2-static.x86_64 : Static library for pcre2
pcre2-tools.x86_64 : Auxiliary utilities for pcre2
pcre2-utf16.i686 : UTF-16 variant of PCRE2
pcre2-utf16.x86_64 : UTF-16 variant of PCRE2
pcre2-utf32.i686 : UTF-32 variant of PCRE2
pcre2-utf32.x86_64 : UTF-32 variant of PCRE2
pcre.i686 : Perl-compatible regular expression library
pcre.x86_64 : Perl-compatible regular expression library
pcre2.i686 : Perl-compatible regular expression library
pcre2.x86_64 : Perl-compatible regular expression library

  Name and summary matches only, use "search all" for everything.
You have new mail in /var/spool/mail/root

develパッケージが必要かな?という事でインストール

# yum install pcre-devel
<~省略~>
Installed:
  pcre-devel.x86_64 0:8.32-17.el7

Complete!

もう一回

# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
<~省略~>
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.46
    Install prefix: /usr/local/apache2
    C compiler:     gcc -std=gnu99
    CFLAGS:           -pthread
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:
    LIBS:
    C preprocessor: gcc -E

できた

make

# make
Making all in srclib
make[1]: Entering directory `/usr/local/src/httpd-2.4.46/srclib'
make[1]: Leaving directory `/usr/local/src/httpd-2.4.46/srclib'
Making all in os

<~省略~>

make[4]: Leaving directory `/usr/local/src/httpd-2.4.46/modules/mappers'
make[3]: Leaving directory `/usr/local/src/httpd-2.4.46/modules/mappers'
make[2]: Leaving directory `/usr/local/src/httpd-2.4.46/modules'
make[2]: Entering directory `/usr/local/src/httpd-2.4.46/support'
make[2]: Leaving directory `/usr/local/src/httpd-2.4.46/support'

make[1]: Leaving directory `/usr/local/src/httpd-2.4.46'

できた

make install

# make install
Making install in srclib
make[1]: Entering directory `/usr/local/src/httpd-2.4.46/srclib'
make[2]: Entering directory `/usr/local/src/httpd-2.4.46/srclib

<~省略~>

Installing build system files
mkdir /usr/local/apache2/build
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/usr/local/src/httpd-2.4.46'

できた。

apache起動

# /usr/local/apache2/bin/apachectl start

# ps axuwf |grep apache
root     29457  0.0  0.0 112812   972 pts/0    S+   06:24   0:00                      \_ grep --color=auto apache
root     29367  0.0  0.1  79164  2528 ?        Ss   06:23   0:00 /usr/local/apache2/bin/httpd
daemon   29368  0.0  0.2 368128  4268 ?        Sl   06:23   0:00  \_ /usr/local/apache2/bin/httpd
daemon   29369  0.0  0.2 368128  4268 ?        Sl   06:23   0:00  \_ /usr/local/apache2/bin/httpd
daemon   29370  0.0  0.2 368128  4268 ?        Sl   06:23   0:00  \_ /usr/local/apache2/bin/httpd

Web閲覧

It works!と表示されることを確認

まとめ

  • 意外とインストールだけならすんなりできた。
  • 後から気づいたが「INSTALL」ファイルを見れば UnixのQuiqStartの記述があった。
  • できればUnitファイルも作成したいけど知識不足
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?