LoginSignup
6
6

More than 5 years have passed since last update.

(覚え書き) col apache2.4のインストール

Posted at

2013/03/22 ごろの作業

Development ToolsやAPRの準備は整っているのでそれほど難しくないと思ったのが大間違い。

ソース入手

http://httpd.apache.org/download.cgi#apache24

にアクセスしてURLを確認

$ wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.4.tar.bz2

さっそくRPMを作成

$ rpmbuild -tb httpd-2.4.4.tar.bz2
エラー: ビルド依存性の失敗:
        pcre-devel >= 5.0 は httpd-2.4.4-1.x86_64 に必要とされています
        lua-devel は httpd-2.4.4-1.x86_64 に必要とされています
        libxml2-devel は httpd-2.4.4-1.x86_64 に必要とされています
        distcache-devel は httpd-2.4.4-1.x86_64 に必要とされています

依存関係で不足しているライブラリをインストール

$ sudo yum install pcre-devel lua-devel libxml2-devel distcache-devel
...()
No package distcache-devel available.
...(略)

distcacheもリポジトリにはないと。

distcacheの入手

http://distcache.sourceforge.net/

から最新版(?)のソースURLを取得。

$ wget http://sourceforge.net/projects/distcache/files/1.%20distcache-devel/1.5.1/distcache-1.5.1.tar.bz2/download
$ rpmbuild -tb distcache-1.5.1.tar.bz2
エラー: distcache-1.5.1.tar.bz2 から spec ファイルの読み込みに失敗しました。

残念。specファイルがないので簡単にはRPMをつくれず。
頑張ってspecファイルを書くというてはありますが知識不足のため、よそからもらってくる...と思ったがFedora系のsrc.rpmもすでに消滅。
仕方ないので自前でBuildする。ということで checkinstallの出番。

checkinstallのセットアップ

http://asic-linux.com.mx/~izto/checkinstall/download.php

にてソースのURLを入手...ではだめでCentOS系ではgitからもってこいとのこと

$ git clone http://checkinstall.izto.org/checkinstall.git
$ cd checkinstall

... 結構手直しが必要とのことなので詳しくはこちら

まずはinstallwatchのMakefileを修正して64bit対応に。

$ cp installwatch/Makefile installwatch/Makefile.old
$ vi installwatch/Makefile
$ diff -u installwatch/Makefile.old installwatch/Makefile
--- installwatch/Makefile.old 2013-03-22 18:00:50.290672394 +0900
+++ installwatch/Makefile 2013-03-22 18:01:46.426673743 +0900
@@ -11,7 +11,12 @@
VERSION=0.7.0beta7


BINDIR=$(PREFIX)/bin
-LIBDIR=$(PREFIX)/lib
+LBITS := $(shell getconf LONG_BIT)
+ifeq ($(LBITS),64)
+ LIBDIR=$(PREFIX)/lib64
+else
+ LIBDIR=$(PREFIX)/lib
+endif


all: installwatch.so

続いて checkinstallrc-dist を修正して RPM/selinux非対応 を標準に。

$ cp checkinstallrc-dist checkinstallrc-dist.old
$ vi checkinstallrc-dist 
$ diff -u checkinstallrc-dist.old checkinstallrc-dist
--- checkinstallrc-dist.old 2013-03-22 18:18:08.850669267 +0900
+++ checkinstallrc-dist 2013-03-22 18:18:47.349672640 +0900
@@ -23,7 +23,7 @@
# included with checkinstall. If you want to use Slackware's native "makepkg"
# then set this to "makepkg"


-MAKEPKG=/sbin/makepkg
+MAKEPKG=


# makepkg optional flags. These are recommended if running a newer Slackware
# version: "-l y -c n"
@@ -49,7 +49,7 @@
# R : RPM
# D : Debian


-INSTYPE=""
+INSTYPE="R"


# Storage directory for newly created packages
# By default they will be stored at the default
@@ -108,7 +108,7 @@
AUTODOINST=1


# Are we going to use filesystem translation?
-TRANSLATE=1
+TRANSLATE=0


# Reset the owner/group of all files to root.root?
RESET_UIDS=0
@@ -117,7 +117,7 @@
NEW_SLACK=1


# Comma delimited list of files/directories to be ignored
-EXCLUDE=""
+EXCLUDE="/selinux"


# Accept default values for all questions?
ACCEPT_DEFAULT=0

さらにcheckinstallrc のインストールパスがなんだかおかしいので修正

$ vi Makefile
$ diff - u Makerfile.org Makefile
--- Makefile.org       2013-04-14 16:38:16.234012738 +0900
+++ Makefile   2013-04-14 14:18:11.238586535 +0900
@@ -4,7 +4,7 @@
 PREFIX=/usr/local
 BINDIR=$(PREFIX)/sbin
 LCDIR=$(PREFIX)/lib/checkinstall/locale
-CONFDIR=$(PREFIX)/lib/checkinstall
+CONFDIR=/etc

 all:
        for file in locale/checkinstall-*.po ; do \

$ vi checkinstall
--- checkinstall.org   2013-04-14 16:38:16.236012738 +0900
+++ checkinstall       2013-04-14 14:18:53.988951022 +0900
@@ -492,7 +492,7 @@
 ckversion
 echo

-CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/checkinstallrc}
+CHECKINSTALLRC=/etc/checkinstallrc
 if ! [ -f $CHECKINSTALLRC ]; then
    echog "The checkinstallrc file was not found at:\n$CHECKINSTALLRC"
    echo

ここでいったんmake&install

$ make
$ sudo make install

エラーがでなければOK.
さらにcheckintall自体のPRM作成。

$ sudo mkdir -p /root/rpmbuild/SOURCES
$ sudo /usr/local/sbin/checkinstall --review-spec --exclude=/selinux
(最初のところで)CTRL+Z
$ sudo rm /etc/checkinstallrc
$ fg
(Enter, Enter, Specファイルを一部修正)
$ sudo ls /root/rpmbuild/RPMS/x86_64
checkinstall-20130322-1.x86_64.rpm

ようやくできあがったのでyumでインストール

$ sudo yum localinstall /root/rpmbuild/RPMS/x86_64/checkinstall-20130322-1.x86_64.rpm

distcacheのRPM作成

CentOSではそのままではbuildエラーするのでソースを一部修正します。

$ tar xjvf distcache-1.5.1.tar.bz2
$ cd distcache-1.5.1
$ vi libnal/proto_fd.c
    #include <limits.h>
$ ./configure --prefix=/usr --libdir=/usr/lib64 --enable-shared
$ make
$ sudo /usr/local/sbin/checkinstall
$ sudo yum localinstall /root/rpmbuild/RPMS/x86_64/distcache-1.5.1-1.x86_64.rpm

distcache-devel ではないのですが、develも含まれているようなのでこれでよしとします(develだけ抜き出せるのが最善ではありますが・・・)

apacheビルド再挑戦

$ cd~
$ rpmbuild -tb httpd-2.4.4.tar.bz2
エラー: ビルド依存性の失敗:
        distcache-devel は httpd-2.4.4-1.x86_64 に必要とされています

確かにdistcache-develはないのでspecファイルを書き換えます。
そしてrpmbuild。

$ tar xjvf httpd-2.4.4.tar.bz2
$ cp httpd-2.4.4/httpd.spec httpd-2.4.4/httpd.spec.old
$ vi httpd-2.4.4/httpd.spec
$ diff -u httpd-2.4.4/httpd.spec httpd-2.4.4/httpd.spec.old
--- httpd-2.4.4/httpd.spec 2013-03-22 20:18:06.396672538 +0900
+++ httpd-2.4.4/httpd.spec.old 2013-02-19 05:28:23.000000000 +0900
@@ -100,7 +100,7 @@
%package -n mod_socache_dc
Group: System Environment/Daemons
Summary: Distcache shared object cache module for the Apache HTTP server
-BuildRequires: distcache
+BuildRequires: distcache-devel
Requires: httpd = %{version}-%{release}, httpd-mmn = %{mmn}


%description -n mod_socache_dc
$ tar cjvf httpd-2.4.4.new.tar.bz2 httpd-2.4.4
$ rpmbuild -tb httpd-2.4.4.new.tar.bz2
$ cd rpmbuild/RPMS/x86_64/

$ ls -lFah httpd-* mod_*
-rw-r--r--. 1 masashi users 1.1M 3月 22 20:19 2013 httpd-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 3.2M 3月 22 20:20 2013 httpd-debuginfo-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 177K 3月 22 20:19 2013 httpd-devel-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 3.0M 3月 22 20:19 2013 httpd-manual-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 67K 3月 22 20:19 2013 httpd-tools-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 42K 3月 22 20:19 2013 mod_authnz_ldap-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 25K 3月 22 20:19 2013 mod_lua-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 22K 3月 22 20:19 2013 mod_proxy_html-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 5.6K 3月 22 20:19 2013 mod_socache_dc-2.4.4-1.x86_64.rpm
-rw-r--r--. 1 masashi users 81K 3月 22 20:19 2013 mod_ssl-2.4.4-1.x86_64.rpm

各種完成。ようやくインストールにたどり着く

$ sudo yum localinstall httpd-2.4.4-1.x86_64.rpm  httpd-devel-2.4.4-1.x86_64.rpm
$ sudo service httpd start
$ wget http://127.0.0.1/
$ cat index.html
<html><body><h1>It works!</h1></body></html>

OK.

iptables の80番解放

外部からアクセスするためにはhttpポートをまずは解放しなければならないのでiptablesをちょろっと変更します。

$ sudo vi /etc/sysconfig/iptables
$ sudo diff -u /etc/sysconfig/iptables.old /etc/sysconfig/iptables
--- /etc/sysconfig/iptables.old 2013-03-18 16:21:01.325484000 +0900
+++ /etc/sysconfig/iptables     2013-03-22 20:46:53.790937255 +0900
@@ -8,6 +8,7 @@
 -A INPUT -p icmp -j ACCEPT
 -A INPUT -i lo -j ACCEPT
 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
 -A INPUT -j REJECT --reject-with icmp-host-prohibited
 -A FORWARD -j REJECT --reject-with icmp-host-prohibited
 COMMIT
$ sudo service iptables restart

Webブラウザでアクセスして「It works!」が表示されることを確認

サービスの自動起動確認

$ sudo chkconfig --list

httpd, mysql が自動起動ONになっているかどうか確認し、なっていない場合は自動起動するようにする

$ sudo chkconfig httpd on
$ sudo chkconfig mysql on

mysqld ではなく mysql である点に注意

6
6
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
6
6