安装apache,php
// yum -y install httpd
[root@bogon ~]# systemctl start httpd
[root@bogon ~]# netstat -lptnu|grep 80
tcp6 0 0 :::80 :::* LISTEN 12463/httpd
// yum -y install php php-fpm
[root@bogon ~]# systemctl start php-fpm
创建一个php的测试页面
// vim /var/www/html/index.php
<?php
phpinfo();
?>
关于防火墙的操作:
列出当前所有的规则
[root@bogon html]# iptables -L
清空所有的规则:
[root@bogon html]# iptables -F
[root@bogon html]# iptables -X
[root@bogon html]# iptables -Z
设置 IPPUT OUTPUT FORWARD 默认规则为DROP (这是危险操作!!)
##给自己留个后门!!
// iptables· -I INPUT -ptcp -s 192.168.1.0/24 -j ACCEPT
// iptables· -I OUTPUT -ptcp -s 192.168.1.0/24 -j ACCEPT
然后再执行:
// iptables -P INPUT DROP
// iptables -P FORWARD DROP
// iptables -P OUTPUT DROP
源ip为192.168.248.101网段,访问端口为80的放行!
iptables -I INPUT -ptcp -s 192.168.248.101/24 --dport 80 -j ACCEPT
关于压测
查看是否有ab压测命令,如果没有,请执行:
// yum -y install httpd-tools
使用ab命令压测:设置请求数:-n100 并发数:-c100
// ab -n100 -c100 http://192.168.1.7/index.php
统计访问web服务 前10的ip
cat /var/log/httpd/access_log |awk '{print $1}'|uniq -c|sort -r|uniq |head -n10|awk '{print $2}'
结合上一条,将访问前10的ip地址给drop掉
#!/bin/bash
for ip in $(cat /var/log/httpd/access_log |awk '{print $1}'|uniq -c|sort -r|uniq |head -n10|awk '{print $2}')
do
#echo $ip
iptables -I INPUT -ptcp -s $ip -j DROP
done
在web目录下批量创建10个(.html)文件
[root@bogon tmp]# vim b.sh
#!/bin/bash
webdir="/var/www/html"
cd $webdir
for i in `seq 10`
do
echo "$i" > $i.html
done
为web目录下的所有的html文件生成md5校验码
#!/bin/bash
webdir="/var/www/html"
cd $webdir
for i in `seq 10`
do
[ -f $i.html ] || echo "$i" > $i.html
done
[ -f /opt/html_md ] || md5sum *.html > /opt/html_md
md5sum -c /opt/html_md > /dev/null
if [ $? -eq 0 ]; then
echo "文件没有篡改"
else
echo "文件被篡改!!"
fi