Migrated from mod_php to php-fpm truble installing extension

ditto

Verified User
Joined
Apr 27, 2009
Messages
2,348
I really need some help here. I have been running php 7.0 with mod_php and mod_ruid2 and imagick extension installed from source, it have worked correct. However I have now changed to use php-fpm, it seems to work correct except I am not able to get imagick extension to work correctly.

imagick extension shows up correct in a phpinfo page, however when I upload a test file like this to a domain:

Code:
<?php
echo "<pre>";
system("which convert"); 
echo "</pre>";
?>

Then I try to visit the domain, it shows a blank page. When the test work correctly it should show this text: /usr/local/bin/convert

Here is a link to a phpinfo page: (removed link because problem now is solved)

Here is how I installed imagick:
Code:
cd /root
wget http://pecl.php.net/get/imagick-3.4.3.tgz
tar zxf imagick-3.4.3.tgz
cd imagick-3.4.3
/usr/local/php70/bin/phpize
./configure --with-php-config=/usr/local/php70/bin/php-config
make
make install

On a different server wich still is using mod_php and it is working, I notice that on phpinfo page under "Environment" section I have this:

Code:
PATH	/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

However as you can see in the phpinfo page linked to above (where imagick is not working correctly), it only have this path under "Environment" section:

Code:
HOME	/home/USERNAME

So I suspect it has something to do with /usr/local/bin not being in the path in phpinfo for the user?

Maybe I should have deleted some old files from the mod_php installation? I really need some help here, completely stuck.
 
Last edited:
I now suspect that it maybe a open_basedir issue. In phpinfo page I have this:

Code:
open_basedir	/home/USERNAME/:/tmp/:/var/tmp/:/usr/local/php70/lib/:/usr/local/php54/lib/:/usr/local/php55/lib/:/usr/local/php56/lib/:/usr/local/php70/lib/:/usr/local/php71/lib/:/usr/local/lib/php/

So I think I need to add /usr/local/bin to open_basedir. I want to add it to all existing and new users/domains. However when using PHP-FPM I am not sure how I can add /usr/local/bin to open_basedir?

I did look at /usr/local/directadmin/custombuild/configure/fpm/conf/php-fpm.conf.70, however the only line regarding open_basedir in that file is commented out and not used.

Anybody now how to add /usr/local/bin to open_basedir for all existing and new users/domains when running PHP-FPM?
 
I have now added /usr/local/bin to /usr/local/directadmin/data/templates/custom/php-fpm.conf - but it did not solve the problem. The test script for imagick is still not able to give output. I tested both with trailing slash and not, I mean I have tested by adding both /usr/local/bin and /usr/local/bin/
 
Last edited:
Are you getting any error messages anywhere? Apache logs / domain.com.error.log?
Maybe check:
Code:
/usr/local/php70/var/log/php-fpm.log
which is another place logs could be stored.

Regarding the PATH variable, I believe that's usually something set well before php is calling the script, set either in the boot script, or whatever the default shell has before php-fpm even starts (can vary). But the "php70" folder is not usually in that variable anyway, so if you're calling any binaries, it's always best to use the absolute /path/to/the/binary you're calling, so the PATH doesn't matter at all.

As for open_basedir, try clearing it right out to nothing eg:
Code:
Admin Level -> Custom Php Config -> domain.com -> php-fpm70
and set the |CUSTOM1| token to be:
Code:
|?OPEN_BASEDIR_PATH=|
so that it's blank.. which should allow everyhing. Just test that to see if it makes any difference.

Without getting any errors, it's difficult to know what the issue actually is..

John
 
There is nothing in /usr/local/php70/var/log/php-fpm.log , also apache error log does noe have anything related.

Regarding the path, the test script does neither work when using full path (/usr/local/bin/convert).

I have now tested by completely disable open_basedir, it did not help.

Remember I did use mod_php before, after changing to PHP-FPM, should I manually delete some of the old files and configs for the old installed mod_php PHP version? Should I delete some of these?:

/usr/local/lib/php
/usr/local/lib/php.conf.d
/usr/local/lib/pkgconfig
 
Last edited:
I did disable open_basedir for the main domain, it is disabled for sure.
 
You migrated i don't know mayby other domain settings from before going to phpfpm still involves here if they aren't updated/changed and ?
where a User has multiple domains, if any one of the domains has safe-mode disabled, it would be disabled for the entire User, thus all the domains in: /usr/local/directadmin/data/users/username/php/php-fpmXX.conf

Try a websearch
imagick php-fpm

results as this
https://www.ateamsystems.com/tech-blog/imagemagick-under-php-fpm-and-chroot/

https://www.imagemagick.org/discourse-server/viewtopic.php?t=25958
 
Last edited:
Back
Top