WebFaction
Community site: login 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 14 Apr '12, 09:19

cedmax
134
accept rate: 0%

edited 14 Apr '12, 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:

<?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:

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!

permanent link

answered 16 Apr '12, 14:28

seanf
12.2k42136
accept rate: 37%

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

(17 Apr '12, 09:30) cedmax

Ok, glad I could help!

(17 Apr '12, 11:22) seanf

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.

permanent link

answered 14 Apr '12, 11:00

iliasr ♦♦
2.2k14
accept rate: 34%

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

(16 Apr '12, 11:42) cedmax
Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×264
×5
×4
×2

question asked: 14 Apr '12, 09:19

question was seen: 4,419 times

last updated: 17 Apr '12, 11:22

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM