du -h --max-depth=1
经常用,这里做一个备份
du -h --max-depth=1
经常用,这里做一个备份
位于/var/log/journal文件夹下面的journal 日志太大,一般系统限制为4GB, 对于一些硬盘比较小的VM就不太友好了
这个是由systemd-journal引起的,我们需要clean it 和limit its growth
Clean Existing Logs
Check current disk usage:
journalctl --disk-usage
Delete logs older than a certain time (e.g., 7 days):
journalctl --vacuum-time=7d
Or limit total size (e.g., 500MB):
journalctl --vacuum-size=500M
Or keep only N logs (e.g., last 10 boots):
journalctl --vacuum-files=10
Prevent Logs from Growing Too Large
Edit the persistent journal configuration:
sudo nano /etc/systemd/journald.conf
Look for or add these lines:
SystemMaxUse=500M SystemKeepFree=100M SystemMaxFileSize=100M SystemMaxFiles=10
Then restart systemd-journald:
sudo systemctl restart systemd-journald
(Optional) Disable Persistent Journaling
If you don’t need persistent logs across reboots:
sudo rm -rf /var/log/journal sudo mkdir /run/log/journal sudo systemctl restart systemd-journald
This means logs will be lost after reboot.
对于我个人来说,我喜欢做如下设置:
journalctl --vacuum-size=200M
然后在/etc/systemd/journald.conf 中设置
SystemMaxUse=200M SystemMaxFileSize=100M
最后重启journald服务
systemcl restart systemd-journald
Supermicro 进入boot meu,需要在启动的时候按F11.
开机界面显示的按Del,是直接进入Bios
即便是同一个文件夹的压缩文件,如果压缩的时间不一样,那么产生的压缩文件的md5值也是不一样的。
原因有三个:
1 Timestamps in Metadata – Many compression tools store file timestamps (creation, modification, and access times) inside the archive. If you compress the same folder at different times, these timestamps may differ, leading to a different MD5 hash.
2 Compression Algorithm Variations – Some compression tools use different compression settings, even if the same files are inside. Small variations in compression level or metadata can result in a different output file and a different MD5 hash.
3 Order of Files – If the compression tool does not always process files in the same order, the resulting archive may be structured differently, leading to a different MD5 hash.
如果想得到固定的MD5值,可以使用如下的三个方法:
1 Hash Individual Files – Instead of hashing the compressed folder, compute MD5 hashes for each file inside the folder and compare them.
2 Use Deterministic Compression – Some tools (like tar –sort=name with gzip –no-name) help create archives with consistent metadata.
3 Exclude Timestamps – Some formats allow you to omit timestamps (e.g., zip –latest-time).
经常利用curl 来测试网站的一些301/302转向,检查代码什么的.
下面是常用的命令, 这里保存一下,经常用的上.
curl -o vue-v2.6.10.js https://cdn.jsdelivr.net/npm/vue/dist/vue.js #vue.js 保存为vue-v2.6.10.js curl -O https://cdn.jsdelivr.net/npm/vue/dist/vue.js # -O 直接保存为原文件名 curl -I https://www.ubuntu.com/ # 获得HTTP HEADER curl -I --http2 https://www.ubuntu.com # --https2 检查是否支持http2协议 curl -L google # -L 命令curl 跟随跳转到final destination curl -A "googlebot" https://www.ubuntu.com # -A 自定义UA curl -x 192.168.66.1:8888 http://linux # -x 或者 --proxy 设定proxy curl -H "X-Header: value" https://www.keycdn.com # -H 自定义header curl -H "X-Header: value" https://www.keycdn.com -v # -v 表示 verbose curl -h # -h 表示manual curl --request GET/POST https://www.keycdn.com # curl 默认是GET, --request 可以自定为GET或者POST
Debian 9, Debian 10 都适用于此教程.
实际上,Nginx 的官方repo编译的nginx,已经把能加上的module全部都加上了,因此在一般情况下,建议使用nginx的官方repo来安装nginx. 但是如果说你想添加第三方的module,或者使用最新的openssl 的话,在或者更改一下nginx 的安装路径的话,就需要自己编译了. 此篇教程尽量按照nginx官方repo的configure来编译安装openssl.
在一台全新安装的Debian 9或者Debian 10上:
用netinst.iso 安装的debian 和 ubuntu,默认都会开启IPv6,但是很多服务商并不分配IPv6,因此大部分的时候我们需要将IPv6 关闭。主要有两种办法,一个是修改sysctl.conf, 或者是在/etc/sysctl.d 目录下创建一个.conf 文件
Method 1:
编辑/etc/sysctl.conf 文件,在文件的最末尾添加下面的entry:
net.ipv6.conf.all.disable_ipv6 = 1
如果仅想关闭某一网卡的ipv6,比如说ens4, 那就可以添加下面的entry:
net.ipv6.conf.ens4.disable_ipv6 = 1
让命令生效:
sysctl -p
Method 2:
在/etc/sysctl.d 目录下创建70-disable-ipv6.conf
nano /etc/sysctl.d/70-disable-ipv6.conf
添加下面的entry:
net.ipv6.conf.all.disable_ipv6 = 1
如果仅仅想关闭某一网卡,比如说ens4, 添加下面的entry:
net.ipv6.conf.ens4.disable_ipv6 = 1
立刻生效:
sysctl -p -f /etc/sysctl.d/70-disable-ipv6.conf
就是这么简单
Debian 9 和 10 的内核自带了google 开发的 BBR 拥塞算法,我们可以很方便的开启BBR 进行访问加速
开启方法:
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p
如果执行之后没有报错,重启一下系统就可以让配置生效.
重启之后,执行如下命令查看内核是否已开启BBR:
sysctl net.ipv4.tcp_available_congestion_control
显示以下即已开启:
root@localhost:~# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno
查看BBR是否启动:
lsmod | grep bbr
显示以下即启动成功:
root@localhost:~# lsmod | grep bbr tcp_bbr 16384 14
Debian 的更新速度太快了,现在Debian 10 已经出来了,但是有的software 还没有支持debian 10
需要安装Debian 9 的, 可以从这个页面下载安装Debian 9
https://www.debian.org/releases/stretch/debian-installer/
在apache 称雄的时代,经常会看到cgi,但是随着nginx 的出现以及时代的进步, cgi 的程序越来越少了.
最近有需求安装smokeping,因此cgi 又被拿了出来
CGI是common gateway interface的缩写,大家都译作通用网关接口,但很不幸,我们无法见名知意。
我们知道,web服务器所处理的内容都是静态的,要想处理动态内容,需要依赖于web应用程序,如php、jsp、python、perl等。但是web server如何将动态的请求传递给这些应用程序?它所依赖的就是cgi协议。没错,是协议,也就是web server和web应用程序交流时的规范。换句话说,通过cgi协议,再结合已搭建好的web应用程序,就可以让web server也能”处理”动态请求(或者说,当用户访问某个特定资源时,可以触发执行某个web应用程序来实现特定功能),你肯定知道处理两字为什么要加上双引号。CGI可以是任何的可执行程序,可以是Shell脚本,二进制应用,或者其他的脚本(Python脚本,Ruby脚本等)
简单的cgi工作方式如下:
有多种方式可以执行cgi程序,但对http的请求方法来说,只有get和post两种方法允许执行cgi脚本。实际上post方法的内部本质还是get方法,只不过在发送http请求时,get和post方法对url中的参数处理方式不一样而已。
任何一种语言都能编写CGI,只不过有些语言比较擅长,有些语言则非常繁琐,例如用bash shell开发,那么需要用echo等打印语句将执行结果放在巨多无比的html的标签中输出给客户端。常用于编写CGI的语言有perl、php、python等,java也一样能写,但java的servlet完全能实现CGI的功能,且更优化、更利于开发
总体上来说,CGI(common gateway interface) 就是所谓的短生存应用程序,Fast CGI 就是所谓的长生存应用程序. FastCGI 像是一个常驻 long-live 型的CGI, 它可以一直执行者,不会每次都要话费时间去fork一次
CGI 和 fastcgi 有自己输入和输出标准,比如HTTP头部, CGI环境变量,get和post等等
CGI, Fast-CGI 是protocols, CGI 慢点, Fast-CGI 要快很多
CGI程序能够用 Python, PERL, Shell, C or C++等语言来实现,尽管没有明确的规定,但是一般用C写的cgi,我们会用.cgi作为后缀,用perl 的用.pl作为后缀,其实我们都可以用.cgi作为后缀. Perl由于其跨操作系统、易于修改的特性成为了CGI的主流编写语言,以至于一般的“cgi程序”就是Perl程序
nginx + fastcgi: nginx只能处理静态文件,对于动态文件,一般用fastcgi 来作为“沟通”的协议. fastcgi 进程由fastcgi 进程管理器管理,而不是nginx,这样就需要一个fastcgi 管理器,这里可以使用spawn-fcgi 作为fastcgi 的进程管理器
nginx + cgi: nginx 不能直接执行外部可执行程序,因此nginx天生不支持cgi的, nginx 虽然不支持cgi,但是他“支持”fastCGI, 这样我们可以fastcgi 来wrap 一下cgi,这样变相的支持cgi,常见的fastcgi wrapper 有fcgiwrap
另外其实cgi 程序也可以被当成fastCGI,因此也可以用nginx + spawn-fcgi 来执行cgi
Spawn-FCGI是一个通用的FastCGI管理服务器,它是lighttpd中的一部份,很多人都用Lighttpd的Spawn-FCGI进行FastCGI模式下的管理工作,不过有不少缺点。而PHP-FPM的出现多少缓解了一些问题
fastcgi 是一个协议, php-fpm 实现了这个协议
通过webserver 来运行php, 一般有两种方式,一个是php-cgi, 另外一个php-fpm (php FastCGI Process Manager) (apache 的mod_php, 把php当作一个模块来执行,以及cli 和 isapi 不在考虑范围之内, php总共来说有5种执行模式)
php-fpm 比传统的CGI方式 (suPHP) 要快,
php-cgi是php自带的fastcgi进程管理器,php-cgi变更php.ini配置后需重启php-cgi才能让新的php-ini生效,不可以平滑重启。另外直接杀死php-cgi进程,php就不能运行了,但是php-fpm和 spawn-fcgi就没有此类问题
php-fpm 就是一个支持php 解析的 fastcgi进程管理器,只能适用于php,其余语言写的cgi,例如perl,python,C,都不能使用
mod_php 和 php-fpm 是运行php 的两种方式,mod_php 是running php as apache module
在segmentfault上看到了一个文章,写的很不错https://segmentfault.com/q/1010000000256516
你(PHP)去和爱斯基摩人(web服务器,如 Apache、Nginx)谈生意
你说中文(PHP代码),他说爱斯基摩语(C代码),互相听不懂,怎么办?那就都把各自说的话转换成英语(FastCGI 协议)吧。
怎么转换呢?你就要使用一个翻译机(PHP-FPM)
(当然对方也有一个翻译机,那个是他自带的)
我们这个翻译机是最新型的,老式的那个(PHP-CGI)被淘汰了。不过它(PHP-FPM)只有年轻人(Linux系统)会用,老头子们(Windows系统)不会摆弄它,只好继续用老式的那个。