PHP网站提升80%加载速度

运行环境:Nginx 1.15 +  PHP-7.0 + MySQL 5.6

优化:
1、安装,并开启BBR或者BBRplus版(低带宽和低内存不推荐使用锐速)
链接:开启BBR
作用:谷歌公司开发BBR对线路流畅程度,有较大的保障。

2、网站开启TLS1.3
必须:Nginx 1.15
网站的配置文件加上TLSv1.3相关配置,如下(不要再使用TLSv1):

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;

作用:开启TLS1.3可以有效减少握手次数,略微缩短访问时间,修改完网站配置需要重启Nigx。

3、安装四个PHP扩展:apcu、opcache、memcached、redis;
特别是redis一定要安装上,提速非常明显。

安装方法……请百度
作用:
apcu、opcache、memcached都是内容缓存,简单易懂。
redis相当于把数据库放入内存中,不需要每次都到硬盘访问数据,提速非常明显。

 

4、禁用高风险函数
文件位置
/www/server/php/版本/etc/php.ini
加固建议, 在/www/server/php/版本/etc/php.ini 中 disable_functions= 修改成如下:

disable_functions = passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,show_source,parse_ini_file,curl_exec,curl_multi_exec,popen,proc_open,pcntl_exec,exec,passthru,shell_exec,system,eval

5、WordPress安装数据库优化插件
https://wordpress.org/support/plugin/wp-optimize/

 

注意:WordPress在大陆使用,需要先替换谷歌字体和部分css、js等,因为谷歌屏蔽了,必须替换,否则载入不了。

Excel合并当前工作簿下的所有工作表

1、新建工作表。

2、右击新建的工作表名称,点击“查看代码(V)”

3、复制输入如下代码:

4、点击F5,运行即可。

BaiduPCS-Go脚本Linux下多线程下载某网盘的文件

BaiduPCS-Go是一位大佬用GO语言写的脚本,可以一键上传、下载、离线下载百度网盘的内容(优点:能突破带宽,批量下载)。

Github地址:https://github.com/iikira/BaiduPCS-Go

两个现成的工具

地址1: https://www.baiduwp.com
地址2: https://baiduwangpan.com

安装

运行一下命令:

  1. 下载
    wget https://github.com/iikira/BaiduPCS-Go/releases/download/v3.5.3/BaiduPCS-Go-v3.5.3-linux-amd64.zip

     

    #自行去Github寻找最新版本和适合的架构

  2. 解压
    unzip BaiduPCS-Go-v3.5.3-linux-amd64.zip

     

    #错误提示可以:sudo apt-get update

  3. 运行

    chmod +x BaiduPCS-Go-v3.5.3-linux-amd64
  4. 进入目录
    cd BaiduPCS-Go-v3.5.3-linux-amd64

使用方法

1、绑定账户

  1. 登陆账户
    ./BaiduPCS-Go login

    #普通登录绑定

  2. 绑定<BDUSS>
    ./BaiduPCS-Go login -bduss=<BDUSS> 

    #BDUSS建议绑定,不知道怎么获取BDUSS请百度

2、设置需要下载到的目录

./BaiduPCS-Go config set -savedir /home/Download   

#下载文件的储存目录

3、列出百度网盘中的文件

./BaiduPCS-Go ls

5、设置最大并发量

 

./BaiduPCS-Go config set -max_parallel 150

 

4、下载百度云目录

  1. 进入百度网盘目录
    ./BaiduPCS-Go cd /

     

  2. 下载“我的软件”文件夹
    ./BaiduPCS-Go d  我的软件

     

5、解决错误代码4, No permission to do this operation

./BaiduPCS-Go config set -appid 309847

VPS服务器一些加速脚本

Linux 发行版在内核版本 4.9 及以上版本中

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

查看BBR是否安装启动:

sysctl net.ipv4.tcp_congestion_control
lsmod | grep bbr

如果结果显示有tcp_bbr模块,则表示BBR已加载到内核中。

  • BBR plus内核4.14.129版(修复CVE-2019-11477内核漏洞)

#支持系统:CentOS 6+、Debian 8+、Debian 10、buntu 14+、Ubuntu 16+

wget  --no-check-certificate -q -O tcp.sh "https://github.com/cx9208/Linux-NetSpeed/raw/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh

 

BBR plus内核升级版
不卸载内核版本

wget -N --no-check-certificate "https://github.000060000.xyz/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh

wget -N "https://github.000060000.xyz/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh

安装完内核之后,reboot 重启 ./tcp.sh 进入管理脚本,开启加速