1. 安裝環境... 4php
2. 安裝步驟... 5html
2.1. 安裝zlib若是要使用apache deflate模塊須要用到zlib... 5linux
2.2. 安裝配置apache. 5web
2.2.1. 編譯並安裝apache. 5apache
2.2.2. 配置apache. 6tomcat
2.2.3. mod_jk.so獲取... 9服務器
1.安裝環境app
OS: SUSE Linux Enterprise Server 10webapp
Apache: 2.2.14socket
Jk: 1.2.28
2.安裝步驟
2.1.安裝zlib若是要使用apache deflate模塊須要用到zlib
# cd /data/postmall/steve
# tar -xzvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在後面加入-fPIC即變成CFLAGS=-O3 -DUSE_MMAP -fPIC
# make
# make install
2.2.安裝配置apache
2.2.1.編譯並安裝apache
從http://httpd.apache.org/download.cgi下載apache 2.2.14版上傳至服務器臨時目錄這裏假設爲/data/postmall/steve
# cd /data/postmall/steve
# tar zxvf httpd-2.2.14.tar.gz
# cd httpd-2.2.14
# vi server/mpm/worker/worker.c
修改
#define DEFAULT_SERVER_LIMIT 512Default 16
#define MAX_SERVER_LIMIT 20000
#define DEFAULT_THREAD_LIMIT 1024 (Default 64)
#define MAX_THREAD_LIMIT 20000
# ./configure --prefix=/usr/local/apache --with-mpm=worker --enable-mods-shared=all --enable-so --enable-most --enable-max --enable-rewrite=shared --enable-speling=shared --enable-deflate=shared --enable-cache=shared --enable-file-cache=shared --enable-proxy=shared --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-proxy-ajp=shared --enable-proxy-balancer=shared
# make
# make install
將/usr/local/apache/lib添加到/etc/ld.so.conf
# echo /usr/local/apache/lib >> /etc/ld.so.conf
# ldconfig
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
確保httpd在系統啓動後自動啓動
# chkconfig --list|grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
若是上面所有顯示爲off則執行
# chkconfig httpd on
以root身份能夠啓動或者中止httpd進程但在配置好以前無需啓動apache
# /sbin/service httpd start (stop, restart)
# mkdir -p /data/logs/apache
2.2.2.配置apache
/usr/local/apache/conf/httpd.conf
將啓動用戶和組改成web 和 users
User web
Group users
增長以下配置使apache能夠順利訪問到/data/postmall目錄
<Directory "/data/postmall">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
增長jk模塊, mod_jk.so文件的獲取參考mod_jk獲取一節
LoadModule jk_module modules/mod_jk.so
## JK Modules Config
JkWorkersFile /usr/local/apache/conf/workers.properties
JkLogFile /data/logs/apache/mod_jk.log
JkLogLevel warn
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkShmFile /data/logs/apache/mod_jk.shm
在DirectoryIndex後增長index.php index.jsp
DirectoryIndex index.html index.php index.jsp
將下面這行前面的#去掉
Include conf/extra/httpd-vhosts.conf
/usr/local/apache/conf/workers.properties (新增文件)
worker.list=ule1
worker.ule1.type=ajp13
worker.ule1.port=8009
worker.ule1.connection_pool_size=256
worker.ule1.connection_pool_timeout=300
worker.ule1.connection_pool_minsize=128
worker.ule1.socket_timeout=300
worker.list=ule2
worker.ule2.type=ajp13
worker.ule2.port=9009
worker.ule2.connection_pool_size=256
worker.ule2.connection_pool_timeout=300
worker.ule2.connection_pool_minsize=128
worker.ule2.socket_timeout=300
/usr/local/apache/conf/extra/httpd-mpm.conf
將原有的mpm_worker配置信息註釋掉用下面的配置
<IfModule mpm_worker_module>
StartServers 5
ServerLimit 128
MaxClients 25600
MinSpareThreads 50
MaxSpareThreads 200
ThreadLimit 384
ThreadsPerChild 256
MaxRequestsPerChild 10000
</IfModule>
/usr/local/apache/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName card.ule.tom.com
ServerAlias card.ulechina.tom.com
DocumentRoot /data/postmall/tomcat/webapps_ulecard/ROOT
JkMount /* ule1
ErrorLog "/data/logs/apache/ulecard-error.log"
CustomLog "/data/logs/apache/ulecard-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerName egiftcard.ule.tom.com
DocumentRoot /data/postmall/tomcat/webapps_egiftcard/ROOT
JkMount /* ule2
ErrorLog "/data/logs/apache/egiftcard-error.log"
CustomLog "/data/logs/apache/egiftcard-access.log" combined
</VirtualHost>
2.2.3. mod_jk.so獲取
從http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/ 根據不一樣的系統平臺以及apache版本下載相應的 .so文件並更名爲mod_jk.so拷貝至 /usr/local/apache/module/下
或者
# tar -zxvf tomcat-connectors-1.2.28-src.tar.gz
# cd tomcat-connectors-1.2.28-src/native
# ./configure --with-apxs=/usr/local/apache/bin/apxs
# make
# cp apache-2.0/mod_jk.so /usr/local/apache/modules/