Apache Implements Web cache optimization

Source: Internet
Author: User

Brief introduction

The Web cache is a page cache that is often not changed or rarely changes, and the next time the browser accesses these pages again, it does not need to download the pages again, thus increasing the user's access speed

Experimental environment
    • System Environment: centos6.5
    • Server IP Address: 192.168.100.103
    • Yum Mount directory:/mnt/sr0
    • Related source package: Baidu Cloud download?? Password: Pko3 build step one, prepare for work 1, shut down the firewall and SELinux

      [Email protected] ~]# chkconfig iptables off #随开机关闭iptables
      [Email protected] ~]# Vim/etc/sysconfig/selinux

[email protected] ~]# reboot #重启生效

2. Uninstall to install httpd related package in RPM mode

[Email protected] ~]# Rpm-qa | grep "httpd"

3. Build a DNS server

If you don't have a friend for the above two services, check out my other posts for more information
http://blog.51cto.com/11905606/2156944

[email protected] ~]# Yum remove httpd #卸载httpd相关包

Second, build Apache service 1, install GCC, gcc-c++, make, ARP, Arp-util, Pcre and other toolkits

[Email protected] ~]# yum-y install gcc gcc-c++ make Zlib-devel #安装C语言编译器以及make

[Email protected] ~]# TAR-ZXVF apr-1.4.6.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/apr-1.4.6/
[[email protected] apr-1.4.6]#./configure prefix=/usr/local/apr && make && make install

[Email protected] ~]# TAR-ZXVF apr-util-1.4.1.tar.gz-c/usr/src/
[Email protected] ~]# CD/USR/SRC/APR-UTIL-1.4.1/
[Email protected] apr-util-1.4.1]#/configure prefix=/usr/local/apr-util--with-apr=/usr/local/apr && Make & amp;& make Install

[Email protected] ~]# TAR-ZXVF pcre-8.10.tar.gz-c/usr/src #支持正则
[Email protected] ~]# cd/usr/src/pcre-8.10/
[[email protected] pcre-8.10]#./configure prefix=/usr/local/pcre && make && make install

2. Configuring and installing Apache

[Email protected] ~]# tar zxvf httpd-2.4.2.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/httpd-2.4.2/
[Email protected] httpd-2.4.2]#/configure \
--PREFIX=/USR/LOCAL/HTTPD \
--WITH-APR=/USR/LOCAL/APR \
--with-pcre=/usr/local/pcre \
--enable-expires \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

parameter resolution:

Prefix: Specifying the installation directory
Enable-expires: Enable Mod_expires module
ENABLE-SO: Enable dynamic load module support, what functions are required to dynamically load
Enable-rewrite: Enable Web address rewriting to implement pseudo-static
Enable-charset-lite: Default Character Set
Enable-cgid: Enable Cgid

[[email protected] httpd-2.4.2]# make && make install #编译及编译安装

3. Adding system Services

[Email protected] ~]# CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD

[Email protected] ~]# VIM/ETC/INIT.D/HTTPD

Lines 2nd, 32 add the following parameters:

# chkconfig:2345 85 15
# Description:apache is a world Wide Web server.

[Email protected] init.d]# chmod +x/etc/init.d/httpd
[Email protected] init.d]# chkconfig--add httpd

4, the establishment of soft links, easy to manage

[Email protected] ~]# mkdir-p/etc/httpd
[Email protected] ~]# ln-s/usr/local/httpd/conf//etc/httpd/#优化配置文件路径
[Email protected] ~]# ln-s/usr/local/httpd/bin/*/usr/local/bin/#优化命令路径

5. Modify the configuration file

[Email protected] ~]# vim/etc/httpd/conf/httpd.conf

Modify the following parameters:

ServerName www.bt.com:80 #填写完全主机名
Listen 192.168.100.103:80 #监听本地IP

6. Start httpd Service

[[Email protected] ~]# service httpd start
[Email protected] ~]# NETSTAT-ANPT | grep ': 80 '

Third, configure Apache to implement the page cache 1, modify the master configuration file

[Email protected] ~]# vim/etc/httpd/conf/httpd.conf

approx. 108 lines turn on the Expires module function:

LoadModule Expires_module modules/mod_expires.so

The last line adds the following:

<ifmodule mod_expires.c>
Expiresactive on #开启expires模块
ExpiresDefault "Access plus seconds" #对于http协议下任意格式的文档 (Html,css,js pictures, etc, expire after 60 seconds)
</IfModule>

2, check whether the Mod_deflate module is installed

[Email protected] ~]# apachectl-t-D dump_modules | grep ' Expires '

[Email protected] ~]#/etc/init.d/httpd restart #重启服务

Iv. using Fiddler to capture the package view

Apache Implements Web cache optimization

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.