Apache module compression and cache settings

Source: Internet
Author: User

1. Opening of the compression function
Yum Remove httpd//Uninstall the original Apache file
Cd/opt/lamp
Tar xzvf httpd-2.4.2.tar.gz-c/opt//manual Compilation installation httpd
Tar xzvf apr-1.4.6.tar.gz-c/opt//Support Apache Upper application cross-platform, provide the bottom interface library
Tar xzvf apr-util-1.4.1.tar.gz-c/opt
Cd/opt
Cp-r apr-1.4.6//OPT/HTTPD-2.4.2/SRCLIB/APR
Cp-r APR-UTIL-1.4.1//opt/httpd-2.4.2/srclib/apr-util
Yum install-y gcc gcc-c++ pcre pcre-devel zlib-devel//Install Environment package (pcre: A Perl library that supports regular expressions)
cd/opt/httpd-2.4.2
./configure \
--PREFIX=/USR/LOCAL/HTTPD \
--enable-deflate \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
Make && make install

Grep-v "#"/usr/local/httpd/bin/apachectl >/ETC/INIT.D/HTTPD//Startup script
VIM/ETC/INIT.D/HTTPD Insert the following line at the front of the file
#!/bin/sh

chkconfig:2345 15description:apache is a world Wide Web server.

chmod +x/etc/init.d/httpd
chkconfig--add httpd
chkconfig--list httpd
chkconfig--level/httpd on//script execution Permissions and start-up
Ln-s/usr/local/httpd/conf/httpd.conf/etc/httpd.conf//Soft connection easy to manage
vim/etc/httpd.conf


CD /usr/local/httpd/bin
./APACHECTL-T//Check syntax for httpd.conf

vim/etc/httpd.conf
LoadModule deflate_module modules/mod_deflate.so//Turn on the compression function module


Insert the following information at the end of the file
<ifmodule mod_deflate.c>
Addoutputfilterbytype DEFLATE text/html text/plain text/css text/xml text/javascript//compressible file types
Deflatecompressionlevel 9//Compression ratio
Setoutputfilter DEFLATE//type of support compression module (DEFLATE)
</IfModule>
./apachectl-t-D dump_modules | grep "deflate"//check whether the compression function module is turned on

2. Cache Settings
./configure \
--PREFIX=/USR/LOCAL/HTTPD \
--enable-deflate \
--enable-expires \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
Make && make install
Grep-v "#"/usr/local/httpd/bin/apachectl >/ETC/INIT.D/HTTPD
VIM/ETC/INIT.D/HTTPD Insert the following line at the front of the file
#!/bin/sh

chkconfig:2345 15description:apache is a world Wide Web server.

chmod +x/etc/init.d/httpd
Chkconfig--add httpd
Chkconfig--list httpd
Chkconfig--level httpd on//execute permissions for scripts and boot from
Ln-s/usr/local/httpd/conf/httpd.conf/etc/httpd.conf
Vim/etc/httpd.conf


LoadModule expires_module modules/mod_expires.so//Open Cache function module

Insert the following information at the end of the file

</IfModule>
<ifmodule mod_deflate.c>
Expiresactive on
ExpiresDefault "Access plus seconds"
</IfModule>

Cd/usr/local/httpd/bin
./apachectl–t//Check syntax is correct

Apache module compression and cache settings

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.