In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Compression of Apache web pages
Definition: a browser that compresses the content of a web page published by an apache server before sending it to the client. It not only reduces the time of network transmission, but also speeds up the loading speed of web pages.
Mod_gzip module and mod_deflate module
1. Both of them use gzip compression algorithm, which works similarly.
2.mod_deflate compression speed is slightly faster, while mod_gzip compression ratio is slightly higher.
3.mod_gzip takes up more server CPU-- a little bit.
4. For high-traffic servers, using mod_deflate may load faster than mod_gzip
Degrees are faster
The experiment begins. 1. The code steps are as follows: [root@localhost ~] # mkdir / aaa [root@localhost ~] # mount.cifs / / 192.168.10.12/rpm / aaaPassword for root@//192.168.10.12/rpm: [root@localhost ~] # cd / aaa [root@localhost aaa] # lsLAMP [root@localhost aaa] # cd LAMP/ [root@localhost LAMP] # lsapr-1.6.2.tar.gz error.pngapr-util-1.6. 0.tar.gz ha.jpgawstats-7.6.tar.gz httpd-2.4.29.tar.bz2cronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26.tar.gzDiscuz_X2.5_SC_UTF8.zip php-5.6.11.tar.bz2 [root@localhost LAMP] # tar jxvf httpd-2.4.29.tar.bz2-C / opt [root@ Localhost LAMP] # tar zxvf apr-1.6.2.tar.gz-C / opt/ [root@localhost LAMP] # tar zxvf apr-util-1.6.0.tar.gz-C / opt [root@localhost LAMP] # cd / opt/ [root@localhost opt] # lsapr-1.6.2 apr-util-1.6.0 httpd-2.4.29 rh [root@localhost opt] # mv apr-1.6.2/ httpd-2.4.29/srclib/apr [root@ Localhost opt] # mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util [root@localhost opt] # yum install gcc gcc-c++ pcre pcre-devel zlib-devel expat-devel-y [root@localhost opt] # cd httpd-2.4.29/ [root@localhost httpd-2.4.29] # lsABOUT_APACHE CMakeLists.txt INSTALL NWGNUmakefileacinclude.m4 config.layout InstallBin.dsp osApache-apr2.dsw configure LAYOUT READMEApache.dsw configure.in libhttpd.dep README.cmakeapache_probes.d docs libhttpd.dsp README.platformsap.d emacs-style libhttpd.mak ROADMAPbuild httpd.dep LICENSE serverBuildAll.dsp httpd.dsp Makefile.in srclibBuildBin.dsp httpd.mak Makefile.win supportbuildconf httpd.spec modules testCHANGES include NOTICE VERSIONING [root@localhost httpd-2.4.29] # / configure-- prefix=/usr/local/httpd-- enable-so-- enable-rewrite-- enable-charset-lite-- enable-cgi [root@localhost httpd-2.4.29] # make [root@localhost httpd-2.4.29] # make install [root@localhost httpd-2.4.29] # cd / usr/local/httpd/ [root@localhost httpd] # lsbin cgi-bin Error icons lib man modulesbuild conf htdocs include logs manual [root@localhost httpd] # cd conf [root@localhost conf] # lsextra httpd.conf magic mime.types original [root@localhost conf] # vim httpd.conf [root@localhost conf] # ln-s / usr/local/httpd/conf/httpd.conf / etc/httpd.conf [root@localhost conf] # vim / etc/httpd.conf / deflate Search for the keyword LoadModule deflate_module modules/mod_deflate.so / / this line needs to remove comments / headers, search for this keyword LoadModule headers_module modules/mod_headers.so / / this line needs to remove comments / filter, search for this keyword LoadModule filter_module modules/mod_filter.so / / this line needs to remove comments / Listen, search for this keyword Listen 192.168.234.172:80#Listen 80/ServerName Search for this keyword ServerName www.kgc.com:80 by the capital letter G to the last line, press o to turn downline to insert AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript text/ipg text/png DeflateCompressionLevel 9 SetOutputFilter DEFLATE// after modification, press Esc to exit Input: wq save and exit [root@localhost conf] # / usr/local/httpd/bin/apachectl-tSyntax OK// to verify whether the syntax is correct [root@localhost conf] # / usr/local/httpd/bin/apachectl start [root@localhost conf] # netstat-ntap | grep 80tcp 0 0192.168.234.172 LISTEN 82881/httpd 80 0.0.0.0 LISTEN 82881/httpd [root@localhost conf] # lsextra Httpd.conf magic mime.types original [root@localhost conf] # cd.. [root@localhost httpd] # lsbin cgi-bin error icons lib man modulesbuild conf htdocs include logs manual [root@localhost httpd] # cd htdocs/ [root@localhost htdocs] # lsindex.html [root@localhost htdocs] # cat index.html It works! [root@localhost htdocs] # cd / usr/local/httpd/bin/ [root@localhost bin] #. / apachectl-t-D DUMP_MODULES | grep "deflate" deflate_module (shared)
2. Add the picture jpg to / htdocs and enter it in index.html
The client accesses the browser through IP and captures it with fiddler
[root@localhost bin] # cd / aaa/LAMP [root@localhost LAMP] # lsapr-1.6.2.tar.gz ha.jpgapr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2awstats-7.6.tar.gz lf.jpgcronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26.tar.gzDiscuz_X2.5_ SC_UTF8.zip php-5.6.11.tar.bz2error.png [root@localhost LAMP] # cp lf.jpg / usr/local/httpd/htdocs/ copy the picture to the corresponding folder [root@localhost LAMP] # cd / usr/local/httpd/ [root@localhost httpd] # cd htdocs/ [root@localhost htdocs] # lsindex.html lf.jpg [root@localhost htdocs] # vim index.html It works!
/ / make the above format changes, insert the picture into it, press Esc to exit, and enter: wq to save and exit.
Conclusion: as long as we embed a format file such as picture or video in the web page, the web page will be compressed and then transmitted to the client of the other party for decompression recognition.
II. Caching of Apache web pages
Definition: part of the page cache that often does not change or changes less. The next time the browser visits these pages, you don't need to download them again. It improves the access speed of the user and reduces the access frequency of the client.
Based on the fact that the configuration file of apache has been set before, we only need to make the following changes:
1. The code is as follows:
[root@localhost htdocs] # vim / etc/httpd.conf press o at the last line to insert the following ExpiresActive On ExpiresDefault "access plus 50 seconds" / / press Esc to exit after modification is complete Input: wq save exit [root@localhost htdocs] # pwd/usr/local/httpd/htdocs [root@localhost htdocs] # cd / usr/local/httpd/ [root@localhost httpd] # cd bin/ [root@localhost bin] #. / apachectl-t / / check syntax Syntax OK [root@localhost bin] #. / apachectl stop [root@localhost bin] #. / apachectl start
2. Verify and test the package.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.