apache的使用

1) download apr1.4.6, apr-util-1.5.1, mod_jk, pcre
http://www.apache.org/dist/apr/  (include apr and apr-util)
http://sourceforge.net/projects/pcre/files/pcre/  
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/

2) install apr
#---------------------------------
tar zxvf apr-1.4.6.tar.gz
./configure --prefix=/opt/apr-1.4.6
./make && make install

3) install apr-util-1.4.1
#---------------------------------
tar zxvf apr-util-1.4.1.tar.gz
./configure --prefix=/opt/apr-util-1.4.1 --with-apr=/opt/apr-1.4.6
make && make install

4) install pcre
tar zxvf pcre-8.30.tar.gz
./configure --prefix=/opt/pcre
make && make install

5) copy apr related source to httpd-2.4.3/srclib/
#avoid Bundled APR requested but not found at ./srclib/ error doing the following copy
cp -rf apr-1.4.6 httpd-2.4.3/srclib/apr
cp -rf apr-util-1.5.1 httpd-2.4.3/srclib/apr-util

6) install apache-2.4.3
#---------------------------------
#./configure --prefix=/opt/apache2.4.3 \
./configure --prefix=/opt/httpd \
--disable-status \
--disable-userdir \
--disable-cgi \
--disable-cgid \
--disable-include \
--disable-autoindex \
--disable-asis \
--disable-imap \
--disable-actions \
--enable-file-cache \
--enable-cache \
--enable-cache-disk \
--enable-ssl \
--with-ssl=/usr/bin/openssl \
--with-mpm=worker \
--sysconfdir=/opt/httpd/conf \
--with-apr=/opt/apr \
--with-apr-util=/opt/apr-util \
--with-pcre=/opt/pcre \
--with-included-apr \

make && make install

7) install tomcat-connector( mod_jk.so)
#---------------------------------
cd /opt/src/tomcat-connectors-1.2.37-src/native
./configure --with-apxs=/opt/httpd/bin/apxs
make && make install
#----------------------------------------

8) edit /opt/httpd/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so
# add by yongcheng.zhou for load balancing begin
JkWorkersFile /opt/www/conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkShmFile logs/mod_jk.shm

<VirtualHost 192.168.0.48:80>
    DocumentRoot /var/www/html
    ServerName www.twd.cn
    ErrorLog logs/twd_error.log
    JkMount /* loadbalancer
    JkMount /balancer-manager/* statusworker
</VirtualHost>
#------------------------------------------

#--------------------------------------------------------------
#  workers.properties
#--------------------------------------------------------------
worker.list=worker1,worker2,loadbalancer,statusworker
# default properties for workers
worker.template.type=ajp13
worker.template.port=8009
worker.template.lbfactor=50
worker.template.connection_pool=50
worker.template.connection_pool_timeout=600
worker.template.socket_keepalive=true
worker.template.socket_timeout=300

# properties for worker1
worker.worker1.reference=worker.template
worker.worker1.host=192.168.0.114

# properties for worker2
worker.worker2.reference=worker.template
worker.worker2.host=192.168.0.115

# properties for loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2
worker.statusworker.type=status
#--------------------------------------------------------------

<IfModule mod_cache.c>
    CacheIgnoreCacheControl On
    CacheIgnoreNoLastMod On
    CacheStoreNoStore On
    CacheStorePrivate On
    CacheEnable mem /images
</IfModule>

<IfModule mod_mem_cache.c>
    MCacheSize 1310720
    MCacheMaxObjectCount 100000
    MCacheMinObjectSize 1
    MCacheMaxObjectSize 1310720
    MCacheMaxStreamingBuffer 1310720
</IfModule>

# install tomcat7
192.168.0.114
192.168.0.115
tar zxvf tomcat*.tar.gz

# open port 8080, 8009 in iptables /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT

#restart iptables
service iptables stop
service iptables start

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。