简体   繁体   English

手动安装 php 扩展(从一台服务器复制到另一台服务器)

[英]Manual Installation of php extension (copy from one server to another)

I am trying to use the following imagick code in my backup server:我正在尝试在我的备份服务器中使用以下 imagick 代码:

<?php

header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');

$image->thumbnailImage(100, 0);

echo $image;

?>

However, this is a backup server which is not having the imagick.so installed.然而,这是一个没有安装 imagick.so 的备份服务器。 Our office has one primary server (same OS version, same linux distribution) with the imagick.so.我们的办公室有一台带有 imagick.so 的主服务器(相同的操作系统版本,相同的 linux 发行版)。 Can I manually copy the imagickso to the backup server and make it working?我可以手动将 imagickso 复制到备份服务器并使其正常工作吗?

Normally you should build the PHP extension in your server thru package management (yum install, or apt-get).通常,您应该通过 package 管理(yum install 或 apt-get)在您的服务器中构建 PHP 扩展。 But if it is not possible then you may try the steps below.但如果不可能,那么您可以尝试以下步骤。

If you have the so file (in your case imagick.so) which is fully functional (and virus free) in a server of EXACTLY the same linux distribution and version.如果您在与 linux 发行版和版本完全相同的服务器中拥有功能齐全(且无病毒)的 so 文件(在您的情况下为 imagick.so)。 You may try to copy the file to your target server path:您可以尝试将文件复制到目标服务器路径:

/usr/lib64/php/modules/imagick.so

or, if the server is 32 bit或者,如果服务器是 32 位

/usr/lib32/php/modules/imagick.so

then open your php.ini (mostly it is /etc/php.ini) and at the end of the file add the following:然后打开您的 php.ini(主要是 /etc/php.ini)并在文件末尾添加以下内容:

extension=imagick.so

After that, restart your apache and it should be ok.之后,重新启动您的 apache 应该没问题。 However, please make sure you can access this server for further troubleshooting because in case of any problem you can revert the changes you have made.但是,请确保您可以访问此服务器以进行进一步的故障排除,因为如果出现任何问题,您可以恢复所做的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM