目录
- yum 升级PHP
- 关于 yum update
- 关于yum中的包名命名规则
- yum 的配置项
- 安装zip扩展
- 安装mongo扩展
- phpize 命令解释
- php-config 命令解释
- 关于多版本的php-fpm的测试验证
centos php 升级
首先先去找官方提供的RPM库
https://rpms.remirepo.net/wizard/
点击如下链接即可
选定操作系统和想要升级到的版本,即可看到相应的帮助文档,照着操作即可。
CentOS 7 provides PHP version 5.4 in its official repository
Command to install the EPEL repository configuration package:
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Command to install the Remi repository configuration package:
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Command to install the yum-utils package (for the yum-config-manager command):
yum install yum-utils
You want a single version which means replacing base packages from the distribution
Packages have the same name than the base repository, ie php-*
Some common dependencies are available in remi-safe repository, which is enabled by default
PHP version 7.3 packages are available for CentOS 7 in remi-php73 repository
Command to enable the repository:
yum-config-manager --enable remi-php73
If the priorities plugin is enabled, ensure remi-php73 have higher priority (a lower value) than base and updates
Command to upgrade (the repository only provides PHP):
yum update
Command to install additional packages:
yum install php-xxx
Command to install testing packages:
yum --enablerepo=remi-php73-test install php-xxx
Command to check the installed version and available extensions:
php --version
php --modules
实际进行操作的时候,执行yum update
貌似连同 nginx
都被更新了。所以看了一下 yum update
的文档,不指定包名就会更新所有已安装的包。 所以如果只是想更新 php
可以 yum update php*
试一试
关于yum update
update 作用于所有已安装的包 要谨慎
If run without any packages, update will update every currently installed package. If one or more packages or package globs are specified, Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied. (See Specifying package names for more information) If the packages or globs specified match to packages which are not currently installed then update will not install them. update operates on groups, files, provides and filelists just like the "install" command.
If the main obsoletes configure option is true (default) or the --obsoletes flag is present yum will include package obsoletes in its calculations - this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9.
Note that "update" works on installed packages first, and only if there are no matches does it look for available packages. The difference is most noticeable when you do "update foo-1-2" which will act exactly as "update foo" if foo-1-2 is installed. You can use the "update-to" if you'd prefer that nothing happen in the above case.
SPECIFYING PACKAGE NAMES
A package can be referred to for install, update, remove, list, info etc with any of the following as well as globs of any of the following:
name
name.arch
name-ver
name-ver-rel
name-ver-rel.arch
name-epoch:ver-rel.arch
epoch:name-ver-rel.arch
For example: yum remove kernel-2.4.1-10.i686
this will remove this specific kernel-ver-rel.arch.
Or: yum list available 'foo*'
will list all available packages that match 'foo*'. (The single quotes will keep your shell from expanding the globs.)
yum-config-manager
manage yum configuration options and yum repositories
yum-config-manager is a program that can manage main yum configuration options, toggle which repositories are enabled or disabled, and add new repositories.
Unless --add-repo is used, the program will output the current configuration of the selected sections, and optionally save it back to the corresponding files.
By default, if no positional arguments are specified, the program will select the [main] section and each enabled repository.
You can override this by specifying your own list of sections as arguments (these may also include disabled repositories). A section can either be main or a repoid.
EXAMPLES
# Show the configuration of [main] and the repos foo and bar:
yum-config-manager main foo bar
# Enable the repos foo and bar:
yum-config-manager --enable foo bar
升级后发现缺少zip包, 安装zip扩展
pecl寻找扩展包 : 首页地址
[root@test01v tmp]# wget http://pecl.php.net/get/zip-1.15.4.tgz
[root@test01v tmp]# tar zxvf zip-1.15.4.tgz
[root@test01v tmp]# cd zip-1.15.4/php73
[root@test01v php73]# phpize
Cannot find config.m4.
Make sure that you run '/bin/phpize' in the top level source directory of the module
[root@test01v tmp]# cd ../zip-1.15.4
[root@test01v zip-1.15.4]# phpize
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
#./configure --with-php-config=/opt/php/bin/php-config (对应的php-config路径)
[root@test01v zip-1.15.4]# ./configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for libzip... not found
configure: error: Please reinstall the libzip distribution
[root@test01v zip-1.15.4]# cd ..
[root@test01v tmp]# wget https://libzip.org/download/libzip-1.3.2.tar.gz
--2019-08-26 16:42:22-- https://libzip.org/download/libzip-1.3.2.tar.gz
Resolving libzip.org (libzip.org)... 5.2.73.210, 2a04:52c0:101:2e6::de6c
Connecting to libzip.org (libzip.org)|5.2.73.210|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1523449 (1.5M) [application/x-gzip]
Saving to: ‘libzip-1.3.2.tar.gz’
100%[==================================================================================================================================================>] 1,523,449 35.7KB/s in 59s
2019-08-26 16:43:25 (25.1 KB/s) - ‘libzip-1.3.2.tar.gz’ saved [1523449/1523449]
[root@test01v tmp]# tar xvf libzip-1.3.2.tar.gz
[root@test01v tmp]# cd libzip-1.3.2
[root@test01v libzip-1.3.2]# ./configure
[root@test01v libzip-1.3.2]# make && make install
[root@test01v libzip-1.3.2]# cd ../zip-1.15.4
[root@test01v zip-1.15.4]# ./configure
[root@test01v zip-1.15.4]# make && make install
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib64/php/modules/
[root@test01v zip-1.15.4]# ll /usr/lib64/php/modules/
total 11044
-rwxr-xr-x 1 root root 36704 Jul 30 23:30 bcmath.so
-rwxr-xr-x 1 root root 24352 Jul 30 23:30 bz2.so
-rwxr-xr-x 1 root root 32416 Jul 30 23:30 calendar.so
-rwxr-xr-x 1 root root 15536 Jul 30 23:30 ctype.so
-rwxr-xr-x 1 root root 86968 Jul 30 23:30 curl.so
-rwxr-xr-x 1 root root 164328 Jul 30 23:30 dom.so
-rwxr-xr-x 1 root root 86064 Jul 30 23:30 exif.so
-rwxr-xr-x 1 root root 5428960 Jul 30 23:30 fileinfo.so
-rwxr-xr-x 1 root root 62048 Jul 30 23:30 ftp.so
-rwxr-xr-x 1 root root 108344 Jul 30 23:30 gd.so
-rwxr-xr-x 1 root root 15656 Jul 30 23:30 gettext.so
-rwxr-xr-x 1 root root 45072 Jul 30 23:30 iconv.so
-rwxr-xr-x 1 root root 487968 Jul 30 23:30 intl.so
-rwxr-xr-x 1 root root 44776 Jul 30 23:30 json.so
-rwxr-xr-x 1 root root 1056272 Jul 30 23:30 mbstring.so
-rwxr-xr-x 1 root root 1061328 Jun 11 13:35 mongodb.so
-rwxr-xr-x 1 root root 137416 Jul 30 23:30 mysqli.so
-rwxr-xr-x 1 root root 253976 Jul 30 23:30 mysqlnd.so
-rwxr-xr-x 1 root root 513208 Jul 30 23:30 opcache.so
-rwxr-xr-x 1 root root 28504 Jul 30 23:30 pdo_mysql.so
-rwxr-xr-x 1 root root 112144 Jul 30 23:30 pdo.so
-rwxr-xr-x 1 root root 28944 Jul 30 23:30 pdo_sqlite.so
-rwxr-xr-x 1 root root 273688 Jul 30 23:30 phar.so
-rwxr-xr-x 1 root root 36872 Jul 30 23:30 posix.so
-rwxr-xr-x 1 root root 15648 Jul 30 23:30 shmop.so
-rwxr-xr-x 1 root root 53928 Jul 30 23:30 simplexml.so
-rwxr-xr-x 1 root root 307120 Jul 30 23:30 soap.so
-rwxr-xr-x 1 root root 91576 Jul 30 23:30 sockets.so
-rwxr-xr-x 1 root root 49992 Jul 30 23:30 sqlite3.so
-rwxr-xr-x 1 root root 15768 Jul 30 23:30 sysvmsg.so
-rwxr-xr-x 1 root root 11528 Jul 30 23:30 sysvsem.so
-rwxr-xr-x 1 root root 15760 Jul 30 23:30 sysvshm.so
-rwxr-xr-x 1 root root 19856 Jul 30 23:30 tokenizer.so
-rwxr-xr-x 1 root root 32672 Jul 30 23:30 wddx.so
-rwxr-xr-x 1 root root 32920 Jul 30 23:30 xmlreader.so
-rwxr-xr-x 1 root root 84256 Jul 30 23:30 xmlrpc.so
-rwxr-xr-x 1 root root 53792 Jul 30 23:30 xml.so
-rwxr-xr-x 1 root root 45048 Jul 30 23:30 xmlwriter.so
-rwxr-xr-x 1 root root 32880 Jul 30 23:30 xsl.so
-rwxr-xr-x 1 root root 223584 Aug 26 16:46 zip.so
[root@test01v zip-1.15.4]# find / -name php.ini
/etc/opt/remi/php73/php.ini
/etc/php.ini
[root@test01v zip-1.15.4]# vim /etc/php.ini
extension="/usr/lib64/php/modules/zip.so"
安装mongo扩展
扩展源码下载地址:http://pecl.php.net/package/mongodb
wget -c https://pecl.php.net/get/mongodb-1.5.4.tgz
tar -zxvf mongodb-1.5.4.tgz
cd mongodb-1.5.4
/www/server/php/72/bin/phpize
./configure --with-php-config=/www/server/php/72/bin/php-config
make && make install
vim /www/server/php/72/etc/php.ini
extension = /www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so
phpize
phpize - prepare a PHP extension for compiling
官方文档,关于使用phpize
编译安装扩展 文档地址
关于多个版本指定特定版本的php-config
php-config
php-config - get information about PHP configuration and compile options
关于升级后测试
通过nginx
配置监听不同端口的php-fpm
来进行测试。