您好,登錄后才能下訂單哦!
配置Apache的網頁壓縮功能,是使用gzip壓縮算法對網頁內容進行壓縮后再傳輸到客戶端瀏覽器
[root@localhost ~]# smbclient -L //192.168.100.23/ #訪問宿主機的共享文件
Enter SAMBA\root's password:
OS=[Windows 10 Enterprise 17763] Server=[Windows 10 Enterprise 6.3]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 遠程管理
C$ Disk 默認共享
D$ Disk 默認共享
E$ Disk 默認共享
F$ Disk 默認共享
G$ Disk 默認共享
IPC$ IPC 遠程 IPC
LAMP Disk
LAMP-C7 Disk
share Disk
Users Disk
Connection to 192.168.100.23 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
[root@localhost ~]# mkdir /abc #創建一個掛載點
[root@localhost ~]# mount.cifs //192.168.100.23/LAMP-C7 /abc/ #掛載
Password for root@//192.168.100.23/LAMP-C7:
[root@localhost ~]# cd /abc
[root@localhost abc]# ls #我們的源碼包都在里面
apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
apr-util-1.6.0.tar.gz fiddler.exe php-5.6.11.tar.bz2
awstats-7.6.tar.gz httpd-2.4.29.tar.bz2
cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt
cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt
[root@localhost abc]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt #解壓到OPT底下
[root@localhost abc]# tar zxvf apr-1.6.2.tar.gz -C /opt/
[root@localhost abc]# tar zxvf apr-util-1.6.0.tar.gz -C /opt/
[root@localhost abc]# cd /opt
[root@localhost opt]# ls
apr-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]# ls
httpd-2.4.29 rh
[root@localhost opt]# cd httpd-2.4.29 /
calhost httpd-2.4.29]#
yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
zlib-devel \
expat-devel \
pcre \
perl
已安裝:
gcc.x86_64 0:4.8.5-39.el7 gcc-c++.x86_64 0:4.8.5-39.el7
pcre-devel.x86_64 0:8.32-17.el7 zlib-devel.x86_64 0:1.2.7-18.el7
作為依賴被安裝:
cpp.x86_64 0:4.8.5-39.el7 glibc-devel.x86_64 0:2.17-292.el7
glibc-headers.x86_64 0:2.17-292.el7 kernel-headers.x86_64 0:3.10.0-1062.4.1.el7
libmpc.x86_64 0:1.0.1-3.el7 libstdc++-devel.x86_64 0:4.8.5-39.el7
作為依賴被升級:
glibc.x86_64 0:2.17-292.el7 glibc-common.x86_64 0:2.17-292.el7
libgcc.x86_64 0:4.8.5-39.el7 libgomp.x86_64 0:4.8.5-39.el7
libstdc++.x86_64 0:4.8.5-39.el7 zlib.x86_64 0:1.2.7-18.el7
完畢!
calhost httpd-2.4.29]#
./configure \
--prefix=/usr/local/httpd \ #指定路徑
--enable-deflate \ #壓縮功能
--enable-so \ #核心模塊開啟
--enable-rewrite \ #開啟重寫功能,防盜鏈
--enable-charset-lite \ #支持字符集
--enable-cgi#通用網關接口
[root@localhost opt]#make
[root@localhost opt]#make install
mkdir /usr/local/httpd/manual
make[1]: 離開目錄“/opt/httpd-2.4.29”
[root@localhost httpd-2.4.29]#
[root@localhost httpd-2.4.29]# cd /usr/local/httpd/
[root@localhost httpd]# ls
bin cgi-bin error icons lib man modules
build conf htdocs include logs manual
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
Listen 192.168.136.136:80 #開啟監聽地址
#Listen 80 #關閉IPV6監聽地址
ServerName www.kgc.com:80 #開啟域名服務器
LoadModule deflate_module modules/mod_deflate.so #前面#去掉開啟功能
#文件末尾加上一段話
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain test/css test/xml test/javascript test/jpg test/png
#支持各種類型的文件
DeflateCompressionLevel 9 #9高壓縮比
SetOutputFilter DEFLATE #默認過濾器
</IfModule>
#檢查語法有沒有錯誤
[root@localhost conf]# /usr/local/httpd/bin/apachectl -t
Syntax OK
[root@localhost conf]# /usr/local/httpd/bin/apachectl start
[root@localhost conf]# netstat -ntap | grep 80
tcp 0 0 192.168.136.136:80 0.0.0.0:* LISTEN 52832/httpd
[root@localhost htdocs]# cd /usr/local/httpd/
[root@localhost httpd]# cd bin/
[root@localhost bin]# systemctl stop firewalld.service
[root@localhost bin]# setenforce 0
[root@localhost bin]# ./apachectl -t -D DUMP_MODULES | grep "deflate"
deflate_module (shared)
[root@localhost abc]# cd /abc/
[root@localhost abc]# ls
apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
apr-util-1.6.0.tar.gz fiddler.exe php-5.6.11.tar.bz2
awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 tu9892_14.jpg #這是我們的圖片
cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt
[root@localhost abc]# cp tu9892_14.jpg /usr/local/httpd/htdocs/ #把這種照片復制到默認首頁中
[root@localhost abc]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ls
index.html tu9892_14.jpg
[root@localhost htdocs]# vim index.html
<html><body><h2>It works!</h2>
<img src="tu9892_14.jpg"/>
</body></html>
通過mod_expire模塊配置Apache,使網頁在客戶端瀏覽器緩存一段時間,以免重復請求,降低客戶段的訪問頻率和次數,達到減少不必要的流量和增加訪問速度的目的
Listen 192.168.136.136:80 #開啟監聽地址
#Listen 80 #關閉IPV6監聽地址
ServerName www.kgc.com:80 #開啟域名服務器
LoadModule expires_module modules/mod_expires.so #開啟模塊
<IfModule mod_expires.c>
ExpiresActive On #開啟功能
ExpiresDefault "access plus 31104000 seconds" #開啟緩存時間31104000s
</IfModule>
[root@localhost conf]# cd /usr/local/httpd/
[root@localhost httpd]# cd bin/
[root@localhost bin]# ./apachectl -t
Syntax OK
[root@localhost bin]# ./apachectl start
[root@localhost bin]# netstat -ntap | grep 80
tcp 0 0 192.168.136.136:80 0.0.0.0:* LISTEN 52832/httpd
[root@localhost bin]# systemctl stop firewalld.service
[root@localhost bin]# setenforce 0
[root@localhost bin]# ./apachectl -t -D DUMP_MODULES | grep "expires"
expires_module (shared)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。