Solarisでapache2.2.3(キャッシュつき)

Solarisでapache2.2.3のビルドをしてみました。7月18日のエントリでapache2.2.2のビルドをしていますが、これはRedhat環境で実施したものです。

apacheのソースはapache.orgのサイトからダウンロードできます。ここWelcome! - The Apache HTTP Server Projectから適当にたどってください。Apache2.2の最新が2.2.3。早速展開して、Redhatと同じようにconfigureをかけてみます。

$ /usr/local/bin/tar -jxvf httpd-2.2.3.tar.bz
$ cd httpd-2.2.3
$  ./configure --with-mpm=worker --enable-ssl --with-ssl=/usr/local/ssl --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-distcache --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-proxy_ajp --enable-module=status
(中略)
checking whether Distcache is required... yes (specified)
checking distcache/dc_client.h usability... no
checking distcache/dc_client.h presence... no
checking for distcache/dc_client.h... no
configure: error: distcache support failed: can't include distcache headers

distcacheがないって言ってます。distcacheはSSLで通信するときのキャッシュに必要なもの(みたい)です。Redhatの環境ではないといっているファイル(dc_client.h)は、/usr/include/distcache以下にあります。早速distcacheをインストール。ここからソースをダウンロードできます。もともとないものなので/usr以下にいれちゃいましょう。

$ /usr/local/bin/tar -jxvf distcache-1.4.5.tar.bz2
$ cd distcache-1.4.5
$ ./configure --prefix=/usr --with-ssl=/usr/local/ssl
$ /usr/local/bin/make
(中略)
/bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I..    -g -O2 -c -o proto_fd.lo `test -f proto_fd.c || echo './'`proto_fd.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I.. -g -O2 -c proto_fd.c -MT proto_fd.lo -MD -MP -MF .deps/proto_fd.TPlo -o proto_fd.o
proto_fd.c: In function 'addr_parse':
proto_fd.c:162: error: 'LONG_MIN' undeclared (first use in this function)
proto_fd.c:162: error: (Each undeclared identifier is reported only once
proto_fd.c:162: error: for each function it appears in.)
proto_fd.c:162: error: 'LONG_MAX' undeclared (first use in this function)
make[2]: *** [proto_fd.lo] Error 1
make[2]: Leaving directory `/export/home/hoge/distcache-1.4.5/libnal'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/export/home/hoge/distcache-1.4.5'
make: *** [all] Error 2

LONG_MINとLONG_MAXってのの定義がないって言ってますね。おかしいな。そんな当たり前の定義が見つからないってどういうことだろ。調べると、この値は/usr/include/sys/types.hと/usr/include/iso/limits_iso.hに定義があります。types.hのほうはこうなっています。

#if defined(_KERNEL)

#define SHRT_MIN        (-32768)        /* min value of a "short int" */
#define SHRT_MAX        32767           /* max value of a "short int" */
#define USHRT_MAX       65535           /* max of "unsigned short int" */
#define INT_MIN         (-2147483647-1) /* min value of an "int" */
#define INT_MAX         2147483647      /* max value of an "int" */
#define UINT_MAX        4294967295U     /* max value of an "unsigned int" */
#if defined(_LP64)
#define LONG_MIN        (-9223372036854775807L-1L)
                                        /* min value of a "long int" */
#define LONG_MAX        9223372036854775807L
                                        /* max value of a "long int" */
#define ULONG_MAX       18446744073709551615UL
                                        /* max of "unsigned long int" */
#else /* _ILP32 */
#define LONG_MIN        (-2147483647L-1L)
                                        /* min value of a "long int" */
#define LONG_MAX        2147483647L     /* max value of a "long int" */
#define ULONG_MAX       4294967295UL    /* max of "unsigned long int" */
#endif

_KERNELってのがdefineされているときだけ有効って書いてるな。じゃこうしてやる。

$ export CFLAGS=-D_KERNEL
$ /usr/local/bin/make distclean
$ ./configure --prefix=/usr --with-ssl=/usr/local/ssl
$ /usr/local/bin/make
source='sys.c' object='sys.lo' libtool=yes \
depfile='.deps/sys.Plo' tmpdepfile='.deps/sys.TPlo' \
depmode=gcc3 /bin/bash ../depcomp \
/bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I..    -D_KERNEL -c -o sys.lo `test -f sys.c || echo './'`sys.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I.. -D_KERNEL -c sys.c -MT sys.lo -MD -MP -MF .deps/sys.TPlo -o sys.o
In file included from /usr/include/sys/procset.h:120,
                 from /usr/local/lib/gcc/sparc-sun-solaris2.9/4.1.1/include/signal.h:82,
                 from ../include/libsys/pre.h:80,
                 from sys.c:23:
/usr/include/sys/proc.h:486: error: conflicting types for 'signal'
/usr/include/iso/signal_iso.h:48: error: previous declaration of 'signal' was here
In file included from ../include/libsys/pre.h:80,
                 from sys.c:23:
/usr/local/lib/gcc/sparc-sun-solaris2.9/4.1.1/include/signal.h:86: error: conflicting types for 'sigsendset'
/usr/include/sys/procset.h:126: error: previous declaration of 'sigsendset' was here
In file included from /usr/local/lib/gcc/sparc-sun-solaris2.9/4.1.1/include/stdlib.h:27,
                 from ../include/libsys/pre.h:83,
                 from sys.c:23:
/usr/include/iso/stdlib_iso.h:100: error: conflicting types for 'exit'
/usr/include/sys/proc.h:448: error: previous declaration of 'exit' was here
sys.c: In function 'int_sig_set':
sys.c:133: error: incompatible types in assignment
make[2]: *** [sys.lo] Error 1
make[2]: Leaving directory `/export/home/hoge/distcache-1.4.5/libsys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/export/home/hoge/distcache-1.4.5'
make: *** [all] Error 2

わはは。適当なことをやったらもっとよくないことになってしまった。DEFINEを有効にしたので、定義にコンフリクトが起きたようです。

じゃあ気を取り直してこんどは/usr/include/iso/limits_iso.hをソースにいれちゃいましょう。proto_df.hのinludeしているところはこうなります。

#define SYS_GENERATING_LIB

#include <iso/limits_iso.h>
#include <libsys/pre.h>
#include <libnal/nal.h>
#include "nal_internal.h"
#include <libsys/post.h>

iso/limits_iso.hの44行から10行くらいにわたってこんなことが書いてあります。

#if defined(_CHAR_IS_SIGNED)
#define CHAR_MIN        SCHAR_MIN       /* min value of a "char" */
#define CHAR_MAX        SCHAR_MAX       /* max value of a "char" */
#elif defined(_CHAR_IS_UNSIGNED)
#define CHAR_MIN        0               /* min value of a "char" */
#define CHAR_MAX        UCHAR_MAX       /* max value of a "char" */
#else
#error "chars are signed or unsigned"
#endif

_CHAR_IS_SINEDか_CHAR_IS_UNSIGNEDかどっちかじゃないとだめだって言うんですね。この場合、CHAR_MINとかCHAR_MAXはdistcacheでは使っていないので今回の場合どっちでも可。というわけでこんな風にやってみます。

$ export CFLAGS=_CHAR_IS_SIGNED
$ ./configure --prefix=/usr --with-ssl=/usr/local/ssl
$ /usr/local/bin/make
(中略)
ar cru .libs/libdistcacheserver.a  dc_server.o dc_server_default.o
ranlib .libs/libdistcacheserver.a
creating libdistcacheserver.la
grep: illegal option -- e
Usage: grep -hblcnsviw pattern file . . .

なんか気になるメッセージが。grepのオプションが無効だっていっています。仕方がない。grepGNUのやつをインストールしてやるか。ソースは例によってGNUftpサイトから。

$ /usr/local/bin/tar -zxvf grep-2.5.1a.tar.gz
$ cd grep-2.5.1a
$ ./configure --prefix=/opt/gnu
$ /usr/local/bin/make
# /usr/local/bin/make install

でもって、distcacheを再ビルド。

$ /usr/local/bin/make distclean
$ export PATH=/opt/gnu/bin:/usr/local/bin:$PATH
$ ./configure --prefix=/usr --with-ssl=/usr/local/ssl
$ /usr/local/bin/make 
# /usr/local/bin/make install

ふぅ。ようやく終わった。エーと何してたんだっけ。あぁそうそう。apacheをビルドしてたんでしたね。

$ cd httpd-2.2.3
$ ./configure --with-mpm=worker --enable-ssl --with-ssl=/usr/local/ssl --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-distcache --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-proxy_ajp --enable-module=status 
(中略)
checking distcache/dc_client.h presence... yes
checking for distcache/dc_client.h... yes
checking for Distcache version... yes
checking for Distcache libraries... no
configure: error: distcache support failed:

またエラーになっちまった。えーと今度はdistcacheのライブラリがおかしいって。config.logを見るとこういっています。

configure:14733: gcc -o conftest -D_CHAR_IS_SIGNED -g -O2 -pthreads  -DSOLARIS2=
9 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE   -L/usr/local/B
erkeleyDB.4.3/lib -L/usr/local/lib -L/usr/local/ssl/lib -R/usr/local/ssl/lib con
ftest.c -lm  -ldistcache -lnal >&5
Undefined                       first referenced
 symbol                             in file
bind                                /usr/lib/libnal.a(util_socket.o)
socketpair                          /usr/lib/libnal.a(util_socket.o)
getsockname                         /usr/lib/libnal.a(util_socket.o)
accept                              /usr/lib/libnal.a(util_socket.o)
listen                              /usr/lib/libnal.a(util_socket.o)
gethostbyname                       /usr/lib/libnal.a(util_socket.o)
socket                              /usr/lib/libnal.a(util_socket.o)
getprotobyname                      /usr/lib/libnal.a(util_socket.o)
setsockopt                          /usr/lib/libnal.a(util_socket.o)
getsockopt                          /usr/lib/libnal.a(util_socket.o)
connect                             /usr/lib/libnal.a(util_socket.o)
ld: fatal: Symbol referencing errors. No output written to conftest
collect2: ld returned 1 exit status
configure:14739: $? = 1

さっき苦労してつくった/usr/lib/libnal.aに未定義シンボルと。このあたりはlibsocketにあるねぇ。じゃ、こうしてみましょう。

$ export LDFLAGS=-lsocket
$ ./configure --with-mpm=worker --enable-ssl --with-ssl=/usr/local/ssl --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-distcache --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-proxy_ajp --enable-module=status 
(中略)
checking for Distcache version... yes
checking for Distcache libraries... no
configure: error: distcache support failed:

またエラーだ。こんどはなんだ。config.logをみる。

configure:14733: gcc -o conftest -D_CHAR_IS_SIGNED -g -O2 -pthreads  -DSOLARIS2=
9 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE -lsocket -L/usr/
local/BerkeleyDB.4.3/lib -L/usr/local/lib -L/usr/local/ssl/lib -R/usr/local/ssl/
lib conftest.c -lm  -ldistcache -lnal >&5
Undefined                       first referenced
 symbol                             in file
gethostbyname                       /usr/lib/libnal.a(util_socket.o)  (symbol be
longs to implicit dependency /usr/lib/libnsl.so.1)
ld: fatal: Symbol referencing errors. No output written to conftest
collect2: ld returned 1 exit status
configure:14739: $? = 1
configure: failed program was:

gethostbynameがない、か。これはlibnls.aにある。

$ export LDFLAGS='-lsocket -lnls'
$ ./configure --with-mpm=worker --enable-ssl --with-ssl=/usr/local/ssl --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-distcache --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-proxy_ajp --enable-module=status 
checking for Distcache version... yes
checking for Distcache libraries... no
configure: error: distcache support failed:
$

だめか。config.logはこう。

configure:6593: checking for bindprocessor
configure:6650: gcc -o conftest  -g -O2 -pthreads  -DSOLARIS2=9 -D_POSIX_PTHREAD
_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE -lsocket -lnls -L/usr/local/Berkel
eyDB.4.3/lib -L/usr/local/lib conftest.c -lm  >&5
Undefined                       first referenced
 symbol                             in file
bindprocessor                       /var/tmp//ccCtiWaD.o
ld: fatal: Symbol referencing errors. No output written to conftest
collect2: ld returned 1 exit status

bindprocessorってなんだ?
あー、もうなんだかわけがわからなくなってきたので、distcacheはやめる方向でいきます。

$ ./configure --with-mpm=worker --enable-ssl --with-ssl=/usr/local/ssl --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-proxy_ajp --enable-module=status
$ /usr/local/bin/make
# /usr/local/bin/make install

なんか最近MeCabといい、この件といいうまくいかないことがおおいなぁ。単純に技術力不足なんだろうけど。




余談

distcacheのソースを展開したディレクトリ中にあるINSTALLファイルのInstallationのセクションはこんなこと書いてあります。

For now, the compilation instructions are very straightforward.
 o Type "./configure"
 o Type "make"
 o Hope

やっぱ、信じることは大切ですね。