大网数据广告活动
服务器运维问答

How to install php-mysql, php-gd and other libraries on Oracle Linux

· 52CE 我爱测

I am trying to install following libraries on Oracle Linux 8 but not working. On Debian 11 after installing php8.1-fpm I run following command and it works. sudo apt install php8.1-mysql php8.1-gd php8.1-mbstring php8.1-xml php8.…

问题原文

原帖链接 · Frank Martin · CC BY-SA 4.0

I am trying to install following libraries on Oracle Linux 8 but not working. On Debian 11 after installing php8.1-fpm I run following command and it works.

sudo apt install php8.1-mysql php8.1-gd php8.1-mbstring php8.1-xml php8.1-zip php8.1-curl php8.1-imagick php8.1-soap

On Oracle Linux I have tried following but no luck. PHP FPM version installed is 7.2.24

sudo yum install php-mysql

sudo yum install php7.2-mysql

sudo yum install php7.2.24-mysql

All these commands failed saying Error: Unable to find a match:

How to install these libraries?

已采纳解答

原帖链接 · Lacek · CC BY-SA 4.0

Change PHP version

First, something of a side note: PHP 7.2 is obsolete, you should use at least PHP 7.4, but 8.0 is preferable. If you don't want to upgrade, skip this section.

You can change the (to-be) installed version of PHP with the following command (you can query the available versions with dnf module list php):

dnf module enable php:8.0

This works only if no packages are installed, however, so if you do have any PHP packages installed (in which case the command above will spit an error), you should issue the following commands:

dnf module reset php
dnf install @php:8.0
dnf distro-sync

Install PHP packages

Use php-mysqlnd instead of php-mysql, and php-pecl-zip instead of php-zip. The cURL extension is in php-common, so you don't need to install any extra packages for that. The rest should exist, except for the ImageMagick extension. For the sake of completeness, here is what you should install:

dnf install php php-common php-mysqlnd php-pecl-zip php-gd \
    php-mbstring php-xml php-soap

Installing the ImageMagick extension is a little bit more tricky. Here is what you should do.

Install the oracle-epel-release-el8 package. It contains the ImageMagick package which you will need.

dnf install oracle-epel-release-el8

Install the ImageMagick and the necessary devel packages:

dnf install ImageMagick ImageMagick-devel php-devel php-pear make

Then use pecl to install the imagick extension:

pecl install imagick

Just accept the default ("autodetect") as the prefix. After this is done, add the extension to the PHP config:

echo "extension=imagick.so" > /etc/php.d/99-imagick.ini

And it is done. The output of php -m should now contain imagick. You will need to restart your web server in order for it to pick up the changed PHP libs.

Note that after this, upgrading PHP will require disabling the imagick extension, and recompiling and re-enabling it after upgrade. Most probably this will be an issue only when changing major versions though.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-08-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。