略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 从 PHP 7.2.x 移植到 PHP 7.3.x

2024-11-14

从 PHP 7.2.x 移植到 PHP 7.3.x

目录

这个新的小版本带来了大量的 新特性少量的兼容性调整 在生产环境切换 PHP 版本前应该进行相关测试。

参见 PHP 版本迁移指南 7.0.x7.1.x7.2.x

add a noteadd a note

User Contributed Notes 1 note

up
0
ben at derrytech dot com
7 months ago
As part of increasing security, it is recommended to keep your version of PHP up to date. Here we have provided the steps to update the current version of PHP 7.2 to 7.3 in Ubuntu versions 14/16/18 / 19/20 without removing the old one. So that we can go back to the previous versions if there is something incompatible with the new one after changing.
    1. Login to the server via SSH as root.
       * If you don't know, it doesn't matter, use the sudo command (like me)
    2. Check your current version of PHP.
       $ php -v
PHP 7.2.36

    3. To install PHP 7.3, we must first add the repository:
       (Be careful here, (CAUTION) ... If you are in Ubuntu 19/20 version, it is not necessary to add repositories, it brings them by default. You can check the repositories with this command:

$ sudo apt-cache policy | grep http | awk '{print $ 2 $ 3}' | sort -u

If app / php or app / apache2 are not found, use this command:

$ sudo add-apt-repository ppa: ondrej / php

    4. Then run an update:
$ sudo apt-get update

    5. After completing the update, we need to install PHP 7.3.
$ sudo apt install php7.3

    6. Then install the required PHP packages according to your current installation:
$ sudo apt install php7.3-common php7.3-cli php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-readline php7.3-xml php7 . 3-zip php7.3-fpm php7.3-bcmath php7.3-mbstring

      New commands are added for version 7.3 of Php. In the order they are written so as not to damage the modules.

Stop Apache Server
$ sudo systemctl stop apache2

Disable Php 7.2 Module
$ sudo a2dismod php7.2

Active Proxy Module fcgi
$ sudo a2enmod proxy_fcgi setenvif

Activate fpm module
$ sudo a2enmod php7.3-fpm

Activate Php 7.3 Module
$ sudo a2enmod php7.3

    7. Then restart Apache:
$ sudo systemctl start apache2
     
    8. Finally we check the Status of the Apache2 Server, turn off and turn on the server a couple of times. (All correct):

$ sudo systenctl status apache2

    9. The new version of PHP should be active now. You can check it from the command line:

$ php -v
PHP 7.3.28

官方地址:https://www.php.net/manual/en/migration73.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3