Debian9 升级PHP7.0至PHP7.2
前期准备
关闭80、443端口,防止apache配置出错导致数据库密码等敏感信息泄漏
配置源
1 2 3 4 |
apt install apt-transport-https ca-certificates wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg sh -c 'echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list' apt update |
安装php7.1(可选)
1 2 3 |
service apache2 stop sudo apt-get install php7.1 php7.1-common sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring |
卸载php7.0并自动安装php7.2
如果之前安装过php,那么会在卸载旧版本php的同时默认同时安装最新版
1 |
apt-get purge php7.0 php7.0-common |
输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
The following packages will be REMOVED: libapache2-mod-php7.0* php7.0* php7.0-bz2* php7.0-cli* php7.0-common* php7.0-curl* php7.0-dev* php7.0-gd* php7.0-intl* php7.0-json* php7.0-mbstring* php7.0-mcrypt* php7.0-mysql* php7.0-opcache* php7.0-readline* php7.0-xml* php7.0-zip* phpmyadmin* pkg-php-tools* The following NEW packages will be installed: libargon2-1 libsodium23 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-phpdbg php7.2-readline php7.2-xml php7.2-zip The following packages will be upgraded: php-bz2 php-curl php-gd php-igbinary php-imagick php-mbstring php-memcache php-mysql php-redis php-xml php-zip 11 upgraded, 15 newly installed, 19 to remove and 55 not upgraded. Need to get 5,354 kB of archives. After this operation, 22.0 MB disk space will be freed. Do you want to continue? [Y/n] y |
输出
1 2 3 4 5 6 7 |
The following packages were automatically installed and are no longer required: dbconfig-common dbconfig-mysql dh-php javascript-common libexporter-tiny-perl libjs-jquery libjs-sphinxdoc libjs-underscore liblist-moreutils-perl libpcre16-3 libpcre3-dev libpcre32-3 libzip4 php-bz2 php-curl php-gd php-mysql php-php-gettext php-phpseclib php-tcpdf php-zip php7.2-bz2 shtool xml2 Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 55 not upgraded. |
安装apache-php7.2扩展
否则apache无法处理php文件会导致直接以文本形式输出
1 |
apt install libapache2-mod-php7.2 |
安装php7.3
1 |
apt install php7.3 |
安装apache-php7.3扩展
1 |
apt install libapache2-mod-php7.3 |
Know More
增加ppa
1 |
add-apt-repository ppa:ondrej/php |
输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided. Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa You can get more information about the packages at https://deb.sury.org BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting CAVEATS: 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman 2. If you are using apache2, you are advised to add ppa:ondrej/apache2 3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline or ppa:ondrej/nginx PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/ WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround: # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php More info: https://launchpad.net/~ondrej/+archive/ubuntu/php Press [ENTER] to continue or ctrl-c to cancel adding it |
输出
1 2 3 4 |
gpg: keybox '/tmp/tmp22b5nobp/pubring.gpg' created gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory gpg: connecting dirmngr at '/run/user/0/gnupg/d.x79onpe8qufrwwythdctq6ke/S.dirmngr' failed: No such file or directory gpg: keyserver receive failed: No dirmngr |
输出
1 |
apt-get install dirmngr |
输出
1 2 3 4 5 6 |
gpg: keybox '/tmp/tmpa_txnhrv/pubring.gpg' created gpg: /tmp/tmpa_txnhrv/trustdb.gpg: trustdb created gpg: key 4F4EA0AAE5267A6C: public key "Launchpad PPA for Ondřej Surý" imported gpg: Total number processed: 1 gpg: imported: 1 gpg: no valid OpenPGP data found. |
删除ppa
1 |
add-apt-repository --remove ppa:ondrej/php |
There are no comments yet