Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache web page optimization-compression, caching

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Experimental environment:

Required software packages: apr-util-1.4.1.tar.gz, httpd-2.4.2.tar.gz, apr-1.4.6.tar.gz

The host shared folder has been hung under / abc

The steps of the experiment:

Compile and install apache manually

-install the package-

Cd / abc

Yum remove httpd-y / / Uninstall the httpd service installed by default

Tar zxvf apr-1.4.6.tar.gz-C / opt

Tar zxvf apr-util-1.4.1.tar.gz-C / opt

Tar zxvf httpd-2.4.2.tar.gz-C / opt

Cd / opt

Cp-R apr-1.4.6/ httpd-2.4.2/srclib/apr

Cp-R apr-util-1.4.1/ httpd-2.4.2/srclib/apr-util

-install the compilation environment-

Yum install gcc gcc-c++ pcre pcre-devel zlib-devel-y

-manually configure and install-

Cd / opt/httpd-2.4.2/

. / configure\

-- prefix=/usr/local/httpd\ / / specify the configuration file path

-- enable-deflate\ / / enable compression

-- enable-expires\ / / enable caching

-- enable-so\ / / enable dynamic module loading

-- enable-rewrite\ / / enable the rewrite function

-- enable-charset-lite\ / / enable character set support

-- enable-cgi / / enable CGI scripting support

Make & & make install

-- set the startup script-

Grep-v "#" / usr/local/httpd/bin/apachectl > / etc/init.d/httpd / / startup script

Vim / etc/init.d/httpd

#! / bin/sh

# chkconfig:2345 85 15

# description:Apache is a World Wide Web server.

Chmod + x / etc/init.d/httpd

Chkconfig-add httpd

Chkconfig-list httpd

Chkconfig-level 35 httpd on

-- establish a soft connection for easy management

Ln-s / usr/local/httpd/conf/httpd.conf / etc/httpd.conf / / establishing a soft connection is easy to manage

Vim / etc/httpd.conf

Listen 192.168.100.20:80

# Listen 80

ServerName www.benet.com:80

Setenforce 0

Service iptables stop

Cd / usr/local/httpd/bin

. / apachectl-t / / check if there is a problem with the syntax

Syntax OK shows no abnormality

Service httpd start

Netstat-ntap | grep 80

2. Enable the transmission compression function

Vim / etc/httpd.conf

LoadModule deflate_module modules/mod_deflate.so / / enable compression function

LoadModule headers_module modules/mod_headers.so / / Open the head

LoadModule filter_module modules/mod_filter.so / / turn on filter

AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript / / File types that support compression

DeflateCompressionLevel 9 / / compression ratio

Compression module mode supported by SetOutputFilter DEFLATE / /

. / apachectl-t

Service httpd restart

. / apachectl-t-D DUMP_MODULES | grep "deflate" / / check whether the module is open

Third, it is better to turn on the cache.

Vim / etc/httpd.conf

LoadModule expires_module modules/mod_expires.so / / Open the cache module

ExpiresActive On

ExpiresDefault "access plus 50 seconds" / / cache time 50s

Content of the experiment:

Compile and install apache manually

For more information, please see the experimental procedure & https://blog.51cto.com/13710287/2135619.

2. Enable the transmission compression function

Third, it is better to turn on the cache.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report