网站改用绝对地址的好处,wordpress创建中英文,策划营销公司企业介绍,怎么让自己的网站通过域名访问不了全部都是面试题
nginx的优化和防盗链
重点就是优化#xff1a;
每一个点都是面试题#xff0c;非常重要#xff0c;都是面试题
1、隐藏版本号#xff08;重点#xff0c;一定要会#xff09;
备份 cp nginx.conf nginx.conf.bak.2023.0805 方法一#xff1a;修改配…全部都是面试题
nginx的优化和防盗链
重点就是优化
每一个点都是面试题非常重要都是面试题
1、隐藏版本号重点一定要会
备份 cp nginx.conf nginx.conf.bak.2023.0805 方法一修改配置文件方式 vim /usr/local/nginx/conf/nginx.conf http { include mime.types; default_type application/octet-stream; server_tokens off; #添加关闭版本号 ...... } systemctl restart nginx curl -I http://192.168.233.61
这时候再来看一下版本号就消失了 方法二修改源码文件重新编译安装 vim /opt/nginx-1.22.0/src/core/nginx.h #define NGINX_VERSION 1.1.1 #修改版本号 #define NGINX_VER IIS NGINX_VERSION #修改服务器类型 cd /opt/nginx-1.22.0/ ./configure --prefix/usr/local/nginx --usernginx --groupnginx --with-http_stub_status_module make make install 回到配置源码包的主目录重新配置一下再重新编译安装一下 装完之后清除一下内存缓存 配置完之后再把off改为on显示编辑的版本号
vim /usr/local/nginx/conf/nginx.conf http { include mime.types; default_type application/octet-stream; server_tokens on; ...... } systemctl restart nginx curl -I http://192.168.233.61 2、Nginx的日志分割非常重要一定要会
Nginx与apache的不同之处就是Nginx本身没有设计日志分割工具所以需要运维人员进行脚本编写来实现日志分割
分割日志 NGINX不自带日志分割系统可以通过脚本实现
vim nginxlog.sh
#!/bin/bash
# 获取日期 date %Y-%m-%d 表示用年 月 日的格式显示 d$(date %Y-%m-%d)
# 定义存储目录 dir/usr/local/nginx/logs
# 定义需要分割的源日志 logs_file/usr/local/nginx/logs/access.log 定义一个变量 logs_error/usr/local/nginx/logs/error.log
#定义nginx的pid文件 pid_file/usr/local/nginx/run/nginx.pid if [ ! -d $dir ] then mkdir $dir fi
# 移动日志并重命名文件 mv ${logs_file} ${dir}/access_${d}.log mv ${logs_error} ${dir}/error_${d}.log
# 发送kill -USR1信号给Nginx的主进程号让Nginx重新生成一个新的日志文件 kill -USR1 $(cat ${pid_file})
#日志文件清理将30天前的日志进行清除 find $logs_path -mtime 30 -exec rm -rf {} \;
ls /var/log/nginx/ #日志按照前一天的日期命名移动到指定路径完成分割的第一步需求
chmod 777 nginxlog.sh