技术学习

WordPress 伪静态规则:Apache、Nginx,和二级目录规则设置

Apache 伪静态规则:

<ifmodule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</ifmodule>

在网站根目录下新建 .htaccess文件,将上面的代码放入保存即可,Apache根目录和子目录一样。

Nginx 伪静态规则:

location / {
    if (-f $request_filename/index.html){
        rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
        rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
        rewrite (.*) /index.php;
    }
}

Nginx 二级目录伪静态:

将”二级目录“替换为你的真实目录路径

location /二级目录/ {
    if (-f $request_filename/index.html){
        rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
        rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
        rewrite (.*) /二级目录/index.php;
    }
}
阅读更多WordPress 伪静态规则:Apache、Nginx,和二级目录规则设置

Ubuntu更换内核并开启BBR加速

## http://kernel.ubuntu.com/~kernel-ppa/mainline/

64位: v4.19.34

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.34/linux-image-unsigned-4.19.34-041934-generic_4.19.34-041934.201904051741_amd64.deb

v4.9.168

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.168/linux-image-4.9.168-0409168-generic_4.9.168-0409168.201904051739_amd64.deb

32位: v4.19.34

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.34/linux-image-4.19.34-041934-generic_4.19.34-041934.201904051741_i386.deb

v4.9.168

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.168/linux-image-4.9.168-0409168-generic_4.9.168-0409168.201904051739_i386.deb

安装

dpkg -i image.deb

删除旧内核

dpkg -l|grep linux-image 
apt-get purge 旧内核

更新grub

/usr/sbin/update-grub
reboot

写入开启

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

保存

sysctl -p

验证

sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control
lsmod | grep bbr
阅读更多Ubuntu更换内核并开启BBR加速

常用Linux命令和快捷工具

非专业运维,仅自用,随缘更新。

  • cat /proc/cpuinfo #cpu
  • lsscsi #物理机看硬盘
  • tar -czvf 1.tar.gz /path #打包压缩
  • tar -zxvf 1.tar.gz #解压
  • tar -tvf 1.tar.gz #不解压查看
  • vi /etc/apt/sources.list
  • iotop -o #io查看
  • ip addr show
  • shutdown -h H:M #定时关机
  • du -sh xx 显示xx文件夹占用空间
  • passwd
  • screen -S (暂离 ctrl+a d) / screen -r (恢复)
  • watch -n 10 uptime #10秒一次命令
  • ncdu

VIM

  • :%s/1/2/g #全文替换1为2
  • o #另起一行

更多:

  • rsync -avz user@host:/path/file file #rsync远程同步,结尾有/不同步根文件夹
  • ls -lSr |more #以尺寸大小排列文件和目录
  • tail -f /log #实时查看
  • dd if=/dev/sda of=/tmp/sda.file #备份sda为一个文件
  • xargs
  • echo -n ‘abc123’|base64

查找和替换

mysql相关

  • mysqldump –single-transaction –quick –skip-add-locks -u username -p mydatabase > backup.sql  #快速导出
  • mysql -u username -p mydatabase < backup.sql #导入
阅读更多常用Linux命令和快捷工具