10

GraphicsMagick and gmagick PHP module on Shared hosting

 3 years ago
source link: https://help.dreamhost.com/hc/en-us/articles/215075007-GraphicsMagick-and-gmagick-PHP-module-on-Shared-hosting
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

GraphicsMagick and gmagick PHP module on Shared hosting

Overview

GraphicsMagick provides a comprehensive collection of utilities, programming interfaces, and GUIs, to support file format conversion, image processing, and 2D vector rendering. View more information at the following link:

Preparing the environment

  1. Log into your server via SSH.
  2. Make sure you're in your user's main directory, not your domain's directory.
  3. Create a build directory where all the required tools are downloaded, configured, and then compiled:
    [server]$ mkdir build
  4. Create a local directory where all the required tools are deployed:
    [server]$ mkdir local

Installing GraphicsMagick

Once you have created the /build and /local directories, proceed with the following commands. This example uses version 1.3.21.

[server]$ cd build
[server]$ wget "ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz"
[server]$ tar zxvf GraphicsMagick-LATEST.tar.gz
[server]$ cd GraphicsMagick-1.3.21
[server]$ ./configure --prefix=$HOME/local --enable-shared --enable-symbol-prefix
[server]$ make
[server]$ make install

If everything runs smoothly, up-to-date GraphicsMagick binaries, libs collection, documentation and so on are available in your local directory (and subdirectory).

Start using this local directory by running the following command:

[server]$ export PATH=$HOME/local/bin:$PATH

Building the gmagick PHP module

  1. Navigate to your /build directory.
    [server]$ cd ~/build
  2. Visit pecl.php.net/package/gmagick and choose the version you wish to use.
  3. Run the following commands based on the version you're using. This example uses 1.1.7RC3.
    [server]$ wget "https://pecl.php.net/get/gmagick-1.1.7RC3.tgz"
    [server]$ tar zxvf gmagick-1.1.7RC3.tgz
    [server]$ cd gmagick-1.1.7RC3
  4. Run the following to ensure that imagick compiles more smoothly. Change the phpize version to the actual PHP version you need to use. View the PHP versions article for details:
    [server]$ /usr/local/php74/bin/phpize
    [server]$ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
    [server]$ ./configure --prefix=$HOME/local --with-gmagick=$HOME/local --with-php-config=/usr/local/php74/bin/php-config
    [server]$ make

    You may see a few compilation warnings. You can safely ignore these. Look for the following which ensures successful installation:

    Libraries have been installed in: 
     /home/username/build/gmagick-1.1.7RC3/modules

Configuring PHP to use this extension

Visit the PHP.ini article for details on how to create a phprc file.

In this example, the domain is running under PHP 7.4. So your phprc file would be in this directory:

Run the following to create your /extensions directory, copy the module and add it to the phprc file:

[server]$ cd ~/.php/7.4
[server]$ mkdir extensions
[server]$ cp ~/build/gmagick-1.1.7RC3/modules/gmagick.so extensions
[server]$ echo "extension = ~/.php/7.4/extensions/gmagick.so" >> phprc

See also

Did this article answer your questions?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK