Bobcares

How to install Imagick in PHP Docker

by | Apr 28, 2022

Install Imagick in PHP Docker like a pro with this handy guide by our experts. 

At Bobcares, we offer solutions for every query, big and small, as a part of our Docker Hosting Support.

Let’s take a look at how our Docker Support Team is ready to help customers with imagick installation in PHP Docker.

How to Install Imagick in PHP Docker

Imagick is a PHP module that plays a critical role in handling images, image conversion, image compression, cropping, and so on. Moreover, it enables our site to deliver images without resulting in scaling issues. This improves the user experience immensely.

install Imagick in PHP Docker

If you are looking for a simple yet effective guide to help you install Imagick in PHP Docker, you have come to the right place. Moreover, the PHP docker image is built from the ground up, thereby the standard apt-get install php-imagick command does not function. In fact, many of our customers find themselves in a pickle after attempting installation in PHP docker with :

run: sudo docker-php-ext-install php-imagick.
run: sudo apt-get install -y aptitude.
run: sudo aptitude install -y php-imagick.
run: sudo apt-get install -y php7-imagick.
sudo aptitude -y install imagemagick.
sudo aptitude -y install libmagickcore-dev.

According to our Support Techs, the docker file for Imgick PHP 7.X should look like the one below:

FROM php:7.3-apache
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick

Build Output:

---> Running in 976ecd4a9627
Removing intermediate container 976ecd4a9627
 ---> 4b978dd49756
Successfully built 4b978dd49756

The docker file for Imgick PHP 8 should look like the one below:

FROM php:8.0.2-apache
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/src/php/ext/imagick; \
    curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1; \
    docker-php-ext-install imagick;

Build Output:

Libraries have been installed in:
   /usr/src/php/ext/imagick/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/include/php/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la      modules/* libs/*
Removing intermediate container 94ca3e4ec9c5
 ---> 0f5f815dccc2
Successfully built 0f5f815dccc2

After the installation, enable Imagick on the hosting account by heading to file Manager under Site in the Site Tools section. Then navigate to the public_html folder and create a new file and save it as php.ini.

With this handy guide, we now have access to Imagick in PHP Docker. If you are still having trouble, contact our experienced Support Engineers for further help.

 

[Need assistance with another query? We are available 24/7.]

Conclusion

In brief, our skilled Docker Support Engineers at Bobcares demonstrated how to go about installing Imagick in PHP Docker.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.