Nginx优化与防盗链

Nginx 隐藏版本

查看方法

[root@localhost bbs]# curl -I http://192.168.235.133

在这里插入图片描述

修改配置文件

[root@localhost conf]# vim nginx.conf

在这里插入图片描述

[root@localhost conf]# systemctl restart nginx
[root@localhost conf]# curl -I http://192.168.235.133

在这里插入图片描述

重新编译安装

[root@localhost nginx-1.15.9]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module
make && make install
[root@localhost nginx-1.15.9]# vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述

[root@localhost nginx-1.15.9]# systemctl stop nginx
[root@localhost nginx-1.15.9]# systemctl start nginx
[root@localhost nginx-1.15.9]# curl I http://192.168.235.133

在这里插入图片描述

设置缓存时间

[root@localhost nginx-1.15.9]# vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[root@localhost html]# vim index.html 

在这里插入图片描述

[root@localhost html]# systemctl restart nginx
[root@localhost html]# curl I http://192.168.235.133/cat.jpg

在这里插入图片描述

日志分割

[root@localhost opt]# vim fenge.sh

在这里插入图片描述

[root@localhost opt]# systemctl start nginx
[root@localhost opt]# netstat -natp | grep nginx

在这里插入图片描述

给与权限执行分割

[root@localhost opt]# chmod +x fenge.sh

在这里插入图片描述

[root@localhost opt]# ls /var/log/nginx

在这里插入图片描述

[root@localhost opt]# crontab -e
crontab: installing new crontab

在这里插入图片描述

连接超时

[root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述

[root@localhost conf]# nginx -t

在这里插入图片描述

更改进程数

[root@localhost conf]# cat /proc/cpuinfo | grep -c "physical"
8
[root@localhost conf]# ps aux | grep nginx

在这里插入图片描述

网页压缩

[root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述

[root@localhost conf]# nginx -t

在这里插入图片描述

[root@localhost html]# vim index.html

在这里插入图片描述

[root@localhost html]# systemctl stop nginx
[root@localhost html]# systemctl start nginx
[root@localhost html]# netstat -natp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      13180/nginx: master 

在这里插入图片描述

防盗链

[root@localhost ~]# vim /etc/hosts

在这里插入图片描述
在这里插入图片描述

C:\WINDOWS\System32\drivers\etc

在这里插入图片描述
在这里插入图片描述

[root@localhost html]# vim index.html

在这里插入图片描述

[root@localhost html]# systemctl start nginx
[root@localhost html]# netstat -natp | grep nginx

在这里插入图片描述
在这里插入图片描述

[root@localhost conf]# vim nginx.conf

在这里插入图片描述

[root@localhost nginx]# cd html/
[root@localhost html]# ls

在这里插入图片描述

[root@localhost html]# nginx -t

在这里插入图片描述

[root@localhost html]# systemctl stop nginx
[root@localhost html]# systemctl start nginx

在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值