First install Apache-dependent APR and Apr-util
1. Download (apr.apache.org/download.cgi) source files, such as apr-1.5.1.tar.gz
2. Unzip TAR-XZVF apr-1.5.1.tar.gz
3. Go to the Unzip directory and execute it sequentially.
123 |
. /configuremakemake Install |
4. Download (apr.apache.org/download.cgi) source files, such as apr-util-1.5.4.tar.gz
5. Unzip TAR-XZVF apr-util-1.5.4.tar.gz
6. Go to the Unzip directory and execute it sequentially.
123 |
. /configure--with-apr=/USR/LOCAL/APR MakeMake install |
Installing Apache
1. Download (httpd.apache.org/download.cgi) source files, such as httpd-2.4.10.tar.gz
2. Unzip TAR-XZVF httpd-2.4.10.tar.gz
3. Go to the Unzip directory and execute it sequentially.
1234 |
. /configure--prefix=/usr/local/apache--enable-so MakeMake install Bin/apachectl-k start #启动apache, access shows it works, indicating installation OK |
4. Add a service
1234 |
CP BIN/APACHECTL/ETC/RC. D/init. D/apache Vim/etc/rc. D/init. D/apache #编辑此文件, add a line: ' #chkconfig: 2345 85 15 ', can be placed on the second line (below #/bin/sh) Chkconfig--add Apache #添加服务 Service Apache Start #启动服务 |
Configure load balancing and session hold
1. Modify apache_home/conf/httpd.conf, add the following module (uncomment, if other dependencies, then uncomment accordingly)
123 |
LoadModule proxy_module Modules/mod_proxy. So LoadModule proxy_http_module modules/mod_proxy_http. So LoadModule proxy_balancer_module Modules/mod_proxy_balancer. So |
2 Modify apache_home/conf/httpd.conf, configure VirtualHost to achieve load balancing and session hold
123456789101112 |
< VirtualHost *> Header add Set-cookie "routeid=.%{balancer_worker_route}e;path=/" Env=balancer_route_changed <!-- Set cookies to enable session-to- Proxyrequests OFF Proxypreservehost on Proxypass/myapp Balancer://proxy/myapp Stickysession=routeid <!--take out the set cookie and go to the appropriate backend server-- < Proxy balancer://proxy> Order Deny,allow Allow from all Balancermember http://150.20.20.91:8001 Route=server1 Balancermember http://150.20.20.92:8001 Route=server2 </Proxy > </VirtualHost > |
- Related articles recommended:
- Install Webalizer to analyze Nginx and Apache logs
- Apache implementation of single IP multi-port mapping method
- Configure Awstats to analyze Nginx and Apache logs
- This article comes from: Hobby Linux
- This article link: http://www.ahlinux.com/apache/9309.html
Apache installation, simple configuration load balancing, and session hold