How to install PHP modules (CentOS)

Phpinfo script creation

When installing modules, you need to get information about PHP parameters on the server. To do this, place phpinfo.php in the site directory.

1. Connect to the server via SSH

cd /path_to_directory

2. In this directory create a file phpinfo.php:

nano phpinfo.php

3. Add content to phpinfo.php file:

<?php

phpinfo();

phpinfo(INFO_MODULES);

?>

4. Press Ctrl + x.

Then press Y and Enter to save changes.

5. Enter http://your.domain.name/phpinfo.php in your browser address bar.

Here you can see data about PHP settings.

Installing modules (for example imagick)

1. Specify the package name.

To install, you need to know the exact name of the package. If you know only part of the package name, you can use this command (for imagick):

yum search ima

As a result of this command, all packages with names starting with "ima" will be displayed

2. To update information from the repositories, enter:

yum update

3. To install the library, enter:

yum install ImageMagick ImageMagick-devel

4. You can install the most common extensions from the PECL repository. You can check the availability of the required extension on the official website.

To install php-pear enter:

yum install php-pear gcc make php-devel

5. Then do (for imagick):

pecl install imagick

6. During installation you will receive a request:

Please provide the prefix of Imagemagick installation

Enter all and confirm with Enter.

7. Check your extension directory:

- enter http: //your.domain.name/phpinfo.php in the browser address bar,

- find the extension_dir parameter, in the line of this parameter the directory for extensions will be displayed,

5. To check if the required library is in the given category:

Change directory for extensions:

cd extension_dir

Enter:

ls library_name

In our case, for the imagick library, you need to enter:

ls imagick

Or you can specify part of the name:

ls imag*

If the library is in the extension directory, it will be displayed in the console.

8. To create a config file and directive execute (for imagick):

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

9. Restart Apache:

systemctl restart httpd

10. Refresh your browser at http: //your.domainname/phpinfo.php.

To check that the installation was successful, find the required module on the page.

Connecting external libraries

You can also link libraries from other sources (not from the repository):

1.  Upload the library file (with the .so extension) to the extension directory.

To find out the address of the directory, enter http: //your.domainname/phpinfo.php in the address bar of your browser. Find the extension_dir parameter, in the line of this parameter the directory for extensions will be displayed.

2. Change to the directory with additional configuration files.

To find out the address of the directory, enter http: //your.domainname/phpinfo.php in the address bar of your browser. Find the Scan this dir for additional.ini files parameter, the line for this parameter will display the directory for additional configuration files.

Change to this directory:

cd directory_address

3. Create a config file:

nano library_name.ini

4. Specify the directive in this file, save the changes:

extension=library_name.so

5. Restart Apache:

systemctl restart httpd

6. Refresh the page http://your.domain.name/phpinfo.php in your browser and check for the name of the installed library there.

If an error occurs and the library file is located in a different directory, at step 4 in the directive, additionally specify the required path:

extension=path_to_library/name_library.so

If you have any questions, please create a ticket to technical support.