byourb 2019-12-29
curl -I http://自己的IP地址
vim /usr/local/nginx/conf/nginx.conf http { include mime.types; default_type application/octet-stream; #下面添加一段,关闭版本显示 server_tokens off;
//先关闭服务,再开启服务 service nginx stop service nginx start
#先把刚才添加的那段话的 off(关闭),改成 on(开启) vim /usr/local/nginx/conf/nginx.conf cd /opt/nginx-1.12.2/src/core/ vim /opt/ningx-1.12.2/src/core/nginx.h define nginx_version 1012002 define NGINX_VERSION "1.1.1" //自定义一个版本号 define NGINX_VER "nginx/" NGINX_VERSION
cd nginx-1.12.2/ ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module make && make install
#在启动服务 service nginx stop service nginx start #在查看,就会发现有一个我们自己伪造的一个版本号 curl -I http://IP地址/ Sercer: nginx/1.1.1 #伪造的版本号
vim /usr/local/nginx/conf/nginx.conf #user nobody; //去掉前面注释符“ # ”,修改 nobody 指定用户与组 nginx nginx;
#在自己的共享文件中 找到" game.jpg " mkdir /abc mount.cifs //192.168.56.1/lamp7 /abc cd /abc/wl //我的图片在wl的包里 //复制图片 game.jpg 到站点目录下 cp /abc/wl/game.jpg /usr/local/nginx/html/ cd /usr/local/nginx/html
#修改 vim index.html #在 Welcome to nginx 的下面添加一段 <img src="game.jpg"/>
vim /usr/local/nginx/conf/nginx.conf #在 http {}段,添加一个 location ~\.(gif|jepg|jpg|ico|bmp|png)$ { root html; expires 1d; }
#重启服务 service nginx restart
vim /opt/fenge.sh #!/bin/bash #Filename:fenge.sh d=$(date -d "-1 day" "+%Y%m%d") logs_path="/var/log/nginx" pid_path="/usr/local/nginx/logs/nginx.pid" [ -d $logs_path ] || mkdir -p $logs_path mv /usr/local/nginx/logs/access.log ${logs_path}/test.com-access.log-$d kill -USR1 $(cat $pid_path) find $logs_path -mtime +30 | xargs rm -rf
chmod +x fenge.sh ./fengs.sh //可以把当前时间修改为2019.12.29,(可以自定义) date -s 2019-12-29
执行周期性计划任务 crontab -e 0 1 * * * /opt/fengs.sh
cd /usr/local/nginx/conf vim nginx.conf #在 http {}段 :下面添加 keepalive_timeout 65 180; client_header_timeout 80; client_body_timeout 80; //重启服务 service nginx restart