星光闪耀有点酷 星光闪耀有点酷
首页
  • 随心随笔

    • 星耀集
    • 热点创作
  • 音乐

    • 尤克里里
  • VuePress
  • Markdown
  • VS Code
  • Node.js
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

星光闪耀

做最酷炫的自己
首页
  • 随心随笔

    • 星耀集
    • 热点创作
  • 音乐

    • 尤克里里
  • VuePress
  • Markdown
  • VS Code
  • Node.js
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • VuePress

  • Markdown

  • VS Code

  • Node.js

  • phpStudy

  • WordPress

  • Linux

    • Linux tmux rzsz 文件卡死快速退出方法
    • Ubuntu 16.04 PHP升级为PHP 7.4
    • 常用命令总结
    • Nginx配置SSL证书 curl (60) Peer's Certificate issuer is not recognized
  • GitHub

  • uni-app

  • 面试题

  • Office

  • Python

  • 技术
  • Linux
星光闪耀
2023-03-20

Ubuntu 16.04 PHP升级为PHP 7.4

环境:

  • Ubuntu 16.04.6 LTS
  • PHP 5.6.40
  • Nginx

目标:

  • 将PHP版本升级为7.4,以应对WordPress提示PHP版本过时问题。

    image

升级步骤:

  1. 将repos.zend.com GPG密钥添加到您的apt密钥链中

    curl -s https://repos.zend.com/zend.key | gpg --dearmor > /usr/share/keyrings/zend.gpg
    
    1
  2. 将repos.zend.com存储库添加到您的apt源列表中

    sudo echo "deb [signed-by=/usr/share/keyrings/zend.gpg] https://repos.zend.com/zendphp/deb_ubuntu1604/ zendphp non-free" > /etc/apt/sources.list.d/zendphp.list
    
    1
  3. 更新您的程序包来源

    sudo apt-get update
    
    1

    如果有报错,则将第2步的命令改为

    sudo echo "deb [arch=amd64 signed-by=/usr/share/keyrings/zend.gpg] https://repos.zend.com/zendphp/deb_ubuntu1604/ zendphp non-free" > /etc/apt/sources.list.d/zendphp.list
    
    1

    然后再去执行

    sudo apt-get update
    
    1

    如果报了如下错:

    E: Failed to fetch https://repos.zend.com/zendphp/deb_ubuntu1604/pool/libapache2-mod-php7.4-zend_7.4.33.2-1_amd64.deb  401  Unauthorized
    
    E: Failed to fetch https://repos.zend.com/zendphp/deb_ubuntu1604/pool/php7.4-zend_7.4.33.2-1_all.deb  401  Unauthorized
    
    1
    2
    3

    则需要去https://www.zend.com/products/zendphp-enterprise/trial 注册一个账号,

    然后执行如下命令:

     sudo \
    echo "machine repos.zend.com login {LOGIN_OR_ORDER_ID} password {PASSWORD}" \
    > /etc/apt/auth.conf.d/zendphp.conf
    
    1
    2
    3

    注:{LOGIN_OR_ORDER_ID}和{PASSWORD}换成实际的,最终的conf文件里没有{}

  4. 安装PHP程序包

sudo apt-get install php7.4-zend
sudo apt-get install php7.4-zend-fpm
sudo update-alternatives --set php /usr/bin/php7.4-zend
sudo apt-get install php7.4-zend-mysql
sudo apt-get install php7.4-zend-curl
sudo apt-get install php7.4-zend-dom
sudo apt-get install php7.4-zend-imagick
sudo apt-get install php7.4-zend-zip
sudo apt-get install php7.4-zend-gd
sudo apt-get install php7.4-zend-intl
sudo apt-get install php7.4-zend-xml
sudo apt-get install php7.4-zend-mbstring
1
2
3
4
5
6
7
8
9
10
11
12
  1. 启动fpm

    sudo systemctl start php7.4-zend-fpm
    
    1
  2. 配置nginx

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-zend-fpm.sock;
    }
    
    1
    2
    3
    4
  3. 重启nginx

    service nginx restart
    
    1
  4. 查看结果

    image

  5. 最终,成功将我们WordPress的PHP版本升级到了7.4.33.2,完美解决问题

    image

参考资料:

Installing ZendPHP on DEB (Debian and Ubuntu) (opens new window)

上次更新: 2023/11/11, 14:53:26
Linux tmux rzsz 文件卡死快速退出方法
常用命令总结

← Linux tmux rzsz 文件卡死快速退出方法 常用命令总结→

最近更新
01
高效学习的方法
11-20
02
学习计划
11-13
03
Nginx配置SSL证书 curl (60) Peer's Certificate issuer is not recognized
05-10
更多文章>
Theme by Vdoing | Copyright © 2013-2024 星光闪耀有点酷 | MIT License
苏公网安备 32072402010152号 | 苏ICP备2022047659号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式