背景
最近偶尔更新博客时,后台会提示
"您的站点正在运行过时版本的 PHP (8.0.8),其无法接收安全更新,且应当被升级。"
国庆假期有空,准备升个级,访问 https://www.php.net/releases/ 发现最新的是今年8月发布的 8.3.25 ,没想到一路踩坑,
过程中的坑点
提示libzip 问题
于是下载编译 libzip,wget -c https://libzip.org/download/libzip-1.11.4.tar.gz 报错
接着编译 libzip ,过程又提示 cmake 没有,要先安装。
- 编译cmake
|
1 2 3 4 5 6 7 8 |
curl -O https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.tar.gz tar -zxvf cmake-3.10.0-Linux-x86_64.tar.gz sudo mv cmake-3.10.0-Linux-x86_64 /usr/local/cmake # 将CMake添加到环境变量 echo 'export PATH=/usr/local/cmake/bin:$PATH' >> ~/.bashrc source ~/.bashrc # 验证版本 cmake --version |
- 继续编译 libzip
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
wget -c https://libzip.org/download/libzip-1.11.4.tar.gz tar -zxvf libzip-1.11.4.tar.gz cd libzip-1.11.4 mkdir build && cd build cmake .. make sudo make install # 将库路径添加到系统配置 echo '/usr/local/lib64' | sudo tee /etc/ld.so.conf.d/local.conf echo '/usr/local/lib' | sudo tee -a /etc/ld.so.conf.d/local.conf # 更新库缓存 sudo ldconfig # 设置 pkg-config 路径 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH # 验证 pkg-config 是否能找到 libzip pkg-config --libs --cflags libzip |
编译 libiconv
接着编译php,发现 提示缺 libiconv,解决下
|
1 2 3 4 5 6 |
cd /root/lnmp1.8-full/src wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz tar -zxvf libiconv-1.17.tar.gz cd libiconv-1.17 ./configure --prefix=/usr/local/libiconv make && make install |
正式编译 php
|
1 2 3 4 5 |
cd /root/lnmp1.8-full/src tar -jxvf php-8.3.25.tar.bz2 cd php-8.3.25 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv=/usr/local/libiconv --with-zip=/usr/local --with-freetype --with-jpeg --with-png --with-zlib --with-libxml-dir --with-curl --with-mhash --with-openssl --with-xmlrpc --with-bz2 --with-gettext --with-xsl --with-zip --with-pear --enable-bcmath --enable-mysqlnd --enable-inline-optimization --enable-sockets --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --enable-exif --enable-calendar --enable-shmop --enable-sysvsem --with-curl --with-mhash --with-openssl --with-xmlrpc --with-bz2 --with-gettext --with-xsl --with-zip --with-pear --enable-bcmath --enable-mysqlnd --enable-inline-optimization --enable-sockets --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --enable-exif --enable-calendar --enable-shmop --enable-sysvsem make && make install |
最新一个报错大致如下
|
1 2 3 4 5 |
cli/php_cli_process_title.o -lresolv -lrt -lstdc++ -liconv -lbz2 -lutil -lrt -lm -ldl -lxml2 -lssl -lcrypto -lsqlite3 -lz -lcurl -lxml2 -lssl -lcrypto -lz -lpng15 -ljpeg -lfreetype -licuio -licui18n -licuuc -licudata -lonig -lsqlite3 -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lz -ldl -lm -lxml2 -lexslt -lxslt -lz -lm -lgcrypt -ldl -lgpg-error -lxml2 -lzip -lbz2 -lz -lz -lssl -lcrypto -lrt -o sapi/cli/php ext/zip/zip_stream.o: In function `php_stream_zip_opener': /root/lnmp1.8-full/src/php-8.3.25/ext/zip/zip_stream.c:347: undefined reference to `zip_file_is_seekable' ext/zip/zip_stream.o: In function `php_stream_zip_open': /root/lnmp1.8-full/src/php-8.3.25/ext/zip/zip_stream.c:261: undefined reference to `zip_file_is_seekable' |
放弃
php 编译依旧是各种报错,放弃高版本升级,先恢复平台访问,下次再升级吧。
这里退回 8.0.30 倒是很顺利。
./upgrade.sh php
Current PHP Version: 这里直接提示没版本了
You can get version number from http://www.php.net/
Please enter a PHP Version you want: 8.0.30
。。。
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.4.14
[PEAR] Console_Getopt - installed: 1.4.3
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.5
warning: pear/PEAR dependency package "pear/Archive_Tar" installed version 1.4.14 is not the recommended version 1.4.4
[PEAR] PEAR - installed: 1.10.13
Warning! a PEAR user config file already exists from a previous PEAR installation at '/root/.pearrc'. You may probably want to remove it.
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/root/lnmp1.8-full/src/php-8.0.30/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin/phar.phar
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
Copy new php configure file...
Modify php.ini......
config-set succeeded
config-set succeeded
Downloading Composer...
--2025-10-13 10:37:59-- https://soft.vpser.net/web/php/composer/composer.phar
Resolving soft.vpser.net (soft.vpser.net)... failed: Name or service not known.
wget: unable to resolve host address ‘soft.vpser.net’
Composer install failed, try to from composer official website...
All settings correct for using Composer
Downloading...
Composer (version 2.8.12) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Composer install successfully.
Install ZendGuardLoader for PHP 8...
unavailable now.
Creating new php-fpm configure file...
Copy php-fpm init.d file...
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
Starting LNMP...
Starting nginx... done
Starting MySQL... SUCCESS!
Starting php-fpm done
======== upgrade php completed ======
文章评论