标签:www exp enforce etc out 移动 star wal enter
配置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><h1>It works!</h1>
<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)
标签:www exp enforce etc out 移动 star wal enter
原文地址:https://blog.51cto.com/14449524/2445328