一、安装时你可能遇到以下问题,可以看看解决办法,如果没有,请直接跳过,看二。
[user@fakeDistnode soft]$cd httpd-2*
[user@fakeDistnode httpd-2.4.6]$./configure help | more
configure: WARNING: you should use --build, --host, --target
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
Invalid configuration `help': machine `help' not recognized
configure: error: /bin/sh build/config.sub help failed
checking build system type...
[user@fakeDistnode httpd-2.4.6]$ ./configure --enable-so --enable-rewrite
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... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
或[user@fakeDistnode httpd-2.4.6]$./configure --enable-so
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... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[user@fakeDistnode httpd-2.4.6]$
pcre-8.33.tar.bz2
需要先 ./configure --prefix=/usr/local/pcre 然而出现以下错误
[user@fakeDistnode pcre-8.33]$ ./configure --with-pcre=/usr/loca/pcre
configure: WARNING: unrecognized options: --with-pcre
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
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 dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for int64_t... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-linux-gnu file names to i686-pc-linux-gnu format... func_convert_file_noop
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for ANSI C header files... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
configure: error: You needa C++ compiler for C++ support.
[user@fakeDistnode pcre-8.33]$ sudo yum install -y gcc gcc-c++
[user@fakeDistnode pcre-8.33]$ ./configure --with-pcre=/usr/local/pcre
configure: WARNING: unrecognized options: --with-pcre
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
之后再(指定服务目录/usr/local/apache2 )
# ./configure --prefix=/usr/local/apache2 --enable-so
# make
# make install
就可以了。
二、单纯安装apache,只提供apache的服务
1、安装Apache。
# cd httpd-2.2.0
# ./configure --prefix=/usr/local/apache2 --enable-so
# make
# make install
修改httpd.conf,参照三修改即可。
三、整合安装安装流程如下:
参考http://blog.csdn.net/yuanxuegui2008/article/details/6038135如下
1、准备,下载需要的文件。这里假定你已经正确安装配置好了JDK。
到Apache官方网站下载所需要的文件:
httpd-2.2.0.tar.gz
apache-tomcat-5.5.12.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz
其中httpd和jakarta-tomcat-connectors为源码包,apache-tomcat直接解压即可。
2、安装Apache。
# cd httpd-2.2.0
# ./configure --prefix=/usr/local/apache2 --enable-so
# make
# make install
3、安装Tomcat。
# cp apache-tomcat-5.5.12.tar.gz /usr/local/
# cd /usr/local
# tar xzvf apache-tomcat-5.5.12.tar.gz
4、编译生成mod_jk。
# tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
# cd jakarta-tomcat-connectors-1.2.15-src/jk/native
# ./configure --with-apxs=/usr/local/apache2/bin/apxs
# make
# cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/
说明
为了更灵活的使用mod_jk连接器,这里我们采用源码方式编译出所需要的JK模块,JK的源码可以从这个地址去下载,http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/,但是不保证此连接永久有效,这里采用的JK版本为jk-1.2.15。
下载后的JK源码压缩包文件为jakarta-tomcat-connectors-current-src.tar.gz,这里也将此压缩包放到/usr/local下,具体安装步骤如下:
[root@webserver ~]# cd /usr/local/
[root@webserver local]# tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
[root@webserver local]# cd jakarta-tomcat-connectors-1.2.15-src/jk/native
[root@webserver native]#chmod 755 buildconf.sh
[root@webserver native]# ./buildconf.sh
[root@webserver native]#./configure \ --with-apxs=/usr/local/apache2/bin/apxs
这里指定的是apache安装目录中apxs的位置
[root@webserver native]# make
[root@webserver native]# make install
[root@webserver native]# cd apache-2.0
[root@webserver native]#ll mod_jk.so
-rwxr-xr-x 1 root root 477305 Oct 9 08:49 mod_jk.so
可以看到有mod_jk.so文件生成,这就是我们需要的JK连接器,默认情况下JK模块会自动安装到/usr/local/apache2/modules目录下,如果没有自动安装到此目录,手动拷贝此文件到modules目录即可。
5、配置。
在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。
# vi mod_jk.conf
添加以下内容:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache2/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/* worker1
JkMount /*.jsp worker1
# vi workers.properties
添加以下内容:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
再配置httpd.conf,作以下修改:
将Listen 80 修改为 Listen 127.0.0.1:80
将ServerName 修改为 ServerName LocalHost:80
在DirectoryIndex中添加 index.jsp
我的网页放在/var/www下,所以要修改DocumentRoot
DocumentRoot "/var/www"
<Directory "/var/www">
Options Includes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
XBitHack on
</Directory>
<Directory "/var/www/WEB-INF">
Order deny,allow
Deny from all
</Directory>
增加关于加载mod_jk的语句:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
最后编辑Tomcat的配置文件server.xml,在HOST段中加入:
<Context path="" docBase="/var/www" debug="0" reloadable="true" crossContext="true"/>
在/var/www下建立一个index.jsp,启动Apache和Tomcat,用浏览器访问http://localhost/,应该可以看到正确的页面了。