[TOC]html
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