环境:SUSE 11 SP1
软件包:httpd-2.2.25.tar.gz、tomcat-connectors-1.2.31-src.tar.gz
步骤
1.创建apache2目录
2.将以上2个tar.gz包上传至apache2目录,解压
cd apache2
tar -zvxf httpd-2.2.25.tar.gz
cd $HOME/apache2/httpd-2.2.25
3.configure
./configure --prefix=$HOME/apache2 --enable-so --enable-mods-shared=most --enable-deflate --enable-expires --enable-headers;
环境上报错如下:
checking for zlib library... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
google结果显示zlib没安装,不过是装了的,如下
NDMC122:/home/ndsc/apache2 # rpm -qa|grep zlib
zlib-1.2.3-106.34
zlib-32bit-1.2.3-106.34
实际上这里去掉--enable-deflate也可以configure成功,但是迟早要装上的,不如彻底解决。
于是决定手动安装zlib,照样是./configure,make,make install,不过在make编译httpd时报错如下:/home/ndsc/apache2/httpd-2.2.25/srclib/apr/libtool --silent --mode=link gcc -g -O2 -pthread -L/usr/local/lib -o mod_deflate.la -rpath /home/ndsc/apache2/modules -module -avoid-version mod_deflate.lo -lz
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[4]: *** [mod_deflate.la] Error 1
参考
http://www.cnblogs.com/qq78292959/archive/2012/05/30/2526761.html ,在./configure前加上CFLAGS="-O3 -fPIC",再make,make install,解决。
4.make、make install
5.安装tomcat-connector
tar -zvxf tomcat-connectors-1.2.31-src.tar.gz
cd $HOME/apache2/tomcat-connectors-1.2.31-src/native/
./configure --with-apxs=$HOME/apache2/bin/apxs;
6.配置tomcat-connector
修改conf/workers.properties