Apache installation, simple configuration of load balancing and session hold

Source: Internet
Author: User
Tags set cookie

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

Make

Make 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

Make

Make 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.