How to enable phpzlib (gzip) compression and output preparation on the entire site 1. cannot find the php_zlib.dll file? Zlib compression has been built into php since php4.3, so at least zlib does not need to be installed in Windows. 2. install and build the php runtime environment because it is impossible to enable the gzip configuration through the php. ini configuration file to implement the phpgzip compression Output. how does one enable the php zlib (gzip) compression output on the entire site?
Preparations
1. cannot find the php_zlib.dll file?
Zlib compression has been built into php since php4.3, so at least zlib does not need to be installed in Windows.
2. install and build the php runtime environment
Since gzip configuration enabled in the php. ini configuration file cannot be used to compress php gzip output, it requires apache support. Therefore, we recommend that you install and build a php + apache + mysql runtime environment.
Php gzip configuration steps
1. open the php. ini configuration file and find zlib. output_compression = Off.
? Zlib. output_compression = Off
; Zlib. output_compression_level =-1
Change
Zlib. output_compression = On
Zlib. output_compression_level = 6
Php gzip configuration knowledge point:
1. by default, php does not enable zlib for full-site compression Output. Instead, it uses the ob_gzhandler function for the page for compression Output. you can only select either of the two. Otherwise, an error is reported.
2. the default value of zlib. output_compression is Off. you can set it to On or output buffer size (4 k by default)
3. zlib. output_compression_level indicates the compression ratio. the default compression ratio is 6. the optional range is 1-9.-1 indicates disabling php zlib (gzip) compression.
2. Save the php. ini configuration file and restart the apache server.
3. open the apache configuration file httpd. conf and configure the deflate_module to be loaded.
This step is the most critical step to enable the php gzip compressed output configuration. many users will say that I have enabled php. the php gzip configuration in the ini configuration file still does not implement php gzip compression, because apache is not loaded with deflate_module. the method is as follows:
? # LoadModule deflate_module modules/mod_deflate.so
Remove the starting # and restart apache.
OK. the page size after php gizp compression is shown below.
Size of the page configured for output after php gzip compression
?
We can see that the size of the output page of the phpinfo () function is 71.7 KB. By configuring php gzip, the size is compressed to 23.9 KB, and the php gzip compression effect is quite impressive.
So far, the configuration tutorial for php zlib (gzip) compression output is completed by modifying the php. ini configuration file.