在虚拟机上远程共享并挂载
[root@localhost ~]# smbclient -L //192.168.100.7/ //远程共享
Enter SAMBA\root's password:
OS=[Windows 10 Home China 18362] Server=[Windows 10 Home China 6.3]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 远程管理
C$ Disk 默认共享
D$ Disk 默认共享
IPC$ IPC 远程 IPC
LAMP-C7 Disk
Users Disk
脚本 Disk
Connection to 192.168.100.7 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.7/LAMP-C7 /abc/ //挂载
Password for root@//192.168.100.7/LAMP-C7:
[root@localhost ~]# cd /abc/
[root@localhost abc]# ls
apr-1.6.2.tar.gz cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt
apr-util-1.6.0.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2
编译安装Apache服务
解压源码包到/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]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt/
[root@localhost abc]# cd /opt/
[root@localhost opt]# ls
apr-1.6.2 apr-util-1.6.0 httpd-2.4.29 httpd.txt rh
移动httpd组件包
[root@lamp opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr
[root@lamp opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util
清除yum缓存,并重新加载yum
[root@lamp opt]# yum clean all
[root@lamp opt]# yum list
安装环境必要软件包
yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
zlib-devel \
expat-devel \
pcre \
perl
配置安装目录及模块
[root@lamp opt]#cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-deflate \
--enable-expires \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
编译安装
[root@localhost httpd-2.4.29]# make
[root@localhost httpd-2.4.29]# make install
配置Apache配置文件
[root@localhost httpd-2.4.29]# vim /usr/local/httpd/conf/httpd.conf
在此配置文件末行下加上以下内容:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/jpg text/javascript text/png
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
</IfModule>
通过测试,查看命令是否正确,并开启服务
[root@localhost httpd-2.4.29]# /usr/local/httpd/bin/apachectl -t
Syntax OK
[root@localhost httpd-2.4.29]# /usr/local/httpd/bin/apachectl start
查看端口状态
[root@localhost httpd-2.4.29]# netstat -ntap | grep 80
tcp 0 0 192.168.35.134:80 0.0.0.0:* LISTEN 35446/httpd
关闭防火墙和增强性安全功能,验证模块
[root@localhost httpd-2.4.29]# systemctl stop firewalld.service
[root@localhost httpd-2.4.29]# setenforce 0
[root@localhost httpd-2.4.29]# cd /usr/local/httpd/bin/
[root@localhost bin]# ./apachectl -t -D DUMP_MODULES | grep "deflate"
deflate_module (shared)
在Windows10上测试验证
打开fiddre软件进行抓包查看
查看自己共享文件夹中的图片,然后复制到网页文件目录下,并将图片添加到网页中
[root@localhost bin]# cd /abc/
[root@localhost abc]# ls
1wp.jpg awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2
apr-1.6.2.tar.gz cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt wp.jpg
apr-util-1.6.0.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
[root@localhost abc]# cp 1wp.jpg /usr/local/httpd/htdocs/
[root@localhost abc]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ls
1wp.jpg index.html
[root@localhost htdocs]# vim index.html
<html><body><h1>It works!</h1>
<img src="1wp.jpg"/>
</body></html>
返回Windows10 再次连接刷新网页
进行抓包,可以看到,图片上传过程中,图片被压缩