Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

trevorpan's avatar

Enabling imagick.so with Envoyer and Forge

So close to launching...

If I understand this correctly. When using both Forge and Envoyer Forge should provision the server & we should not place the recipes in Forge's dashboard. We should use the deployment hooks in Envoyer, right?

If that's so, I found a great site for Forge https://forgerecipes.com/recipes/215

It seems like that same recipe could be used as a deployment hook here:

cd {{release}}
#!/bin/bash

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi


apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install libmagickwand-dev
yes '' | sudo pecl install imagick

bash -c "echo extension=imagick.so > /etc/php/7.3/mods-available/imagick.ini"
ln -s /etc/php/7.3/mods-available/imagick.ini /etc/php/7.3/cli/conf.d/20-imagick.ini
ln -s /etc/php/7.3/mods-available/imagick.ini /etc/php/7.3/fpm/conf.d/20-imagick.ini
service php7.3-fpm restart

But this gives this error:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)

I have ssh'd into the server to try to edit the php.ini file but get: [ File '/etc/php/7.3/cli/php.ini' is unwritable ] I have also enabled the php.ini file in Forge under files with extension=imagick.co but it does not seem to have any effect when deploying from Envoyer.

This article helped out quite a bit, but did not address pecl stuff. https://medium.com/@ted.nugent/laravel-forge-envoyer-cloudforge-ssl-and-you-cc0cc51db945

Any ideas?

Thank you much`

0 likes
1 reply
trevorpan's avatar
trevorpan
OP
Best Answer
Level 15

Was on a slack channel and was able to get this to work.

For anyone a little confused like me, use recipes for things like extensions and deployment hooks for artisan commands. (generally)

#!/bin/bash

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi


apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install libmagickwand-dev
yes '' | sudo pecl install imagick

bash -c "echo extension=imagick.so > /etc/php/7.3/mods-available/imagick.ini"
ln -s /etc/php/7.3/mods-available/imagick.ini /etc/php/7.3/cli/conf.d/20-imagick.ini
ln -s /etc/php/7.3/mods-available/imagick.ini /etc/php/7.3/fpm/conf.d/20-imagick.ini
service php7.3-fpm restart

This code was able to implement the extension.

Please or to participate in this conversation.