login community faq

I have a wordpress based website and I installed a plugin that requires opt-png, opt-gif and opt-jpg cli commands to optimize images.

I installed them in my account, but still the <?php var_dump(exec('which opt-gif')) ?> - and the other as well - is reporting an empty string and the plugin is not working.

How do I solve it?

Thanks Marco

asked Apr 14 '12 at 09:19

cedmax's gravatar image

cedmax
11

edited Apr 14 '12 at 09:20


The problem is that the PATH environment used by our PHP setup does not include your ~/bin directory, so PHP cannot locate your locally-installed utilities.

You can work around it by setting the PATH as follows (replace "username" and "appname" with the appropriate values):

First, create /home/username/webapps/appname/set_path.php with the following contents:

1
2
3
4
<?php
  $_SERVER['PATH'] = '/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/username/bin';
  $_ENV['PATH'] = '/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/username/bin';
?>

Next, create /home/username/webapps/appname/php.ini with the following contents:

1
auto_prepend_file = "/home/username/webapps/appname/set_path.php"

Once that's done, PHP should be able to find your utilities and run them.

Hope that helps!

answered Apr 16 '12 at 14:28

seanf's gravatar image

seanf ♦♦
56441220

thanks a lot: I supposed the problem was the PATH, but I didn't know how to resolve it.

(Apr 17 '12 at 09:30) cedmax cedmax's gravatar image

Ok, glad I could help!

(Apr 17 '12 at 11:22) seanf ♦♦ seanf's gravatar image

Maybe you've installed those binaries in a directory not listed in the enviroment variable PATH, thus which (or the apache server) can't find them.

You should start an ssh shell and verify that you can run those commands successfully and if not edit your .bashrc file accordingly.

If you need further assistance, please open a support ticket so we can take a better look in your configuration, as it is a bit difficult to know the exact cause of this issue without access to your account.

answered Apr 14 '12 at 11:00

iliasr's gravatar image

iliasr ♦♦
7013

actually I can run them by console, I'm not able to run them only via php, is there any different configuration I'm supposed to do? otherwise I will open the ticket thanks

(Apr 16 '12 at 11:42) cedmax cedmax's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×146
×4
×2
×2

Asked: Apr 14 '12 at 09:19

Seen: 627 times

Last updated: Apr 17 '12 at 11:22

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited