On Jan 8, 2009, at 04:56, sheldon wrote:

Rainer Müller <raimue <at> macports.org> writes:

Try to set PATH including /opt/local/bin in the httpd.conf for the
corresponding vhost (or even global).

See <http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv>

HTH,
Rainer

Thanks for the idea, I've tried this approach. Unfortunately it seems to have no effect on the path that mod_php actually sees. I'm not sure if it's an apache
security thing or something else.

Is there any chance anyone would know why this wouldn't work?

SetEnv PATH $PATH:/opt/local/bin

I do not know. Perhaps Apache does not pass the PATH to mod_php. You should probably ask in a PHP support forum if you want to pursue this.


When I used to write web pages that used binaries which could be in different locations, I would use constants, e.g. in a config file:

<?php
define('IDENTIFY', '/opt/local/bin/identify');
?>

Then in the code where I wanted to run identify:

<?php
require_once 'config.php';
exec(IDENTIFY . ' 2>&1', $output, $error_code);
?>

This way there's only one place (the config file) where you have to change the paths and not hunt all over your code.


In addition, you can write the config file in such a way that it adapts itself to the machine it's running on:

<?php
if (defined('PRODUCTION_SERVER') && PRODUCTION_SERVER) {
        define('IDENTIFY', '/usr/local/bin/identify';
} else if (defined('DEVELOPMENT_SERVER') && DEVELOPMENT_SERVER) {
        define('IDENTIFY', '/opt/local/bin/identify';
} else {
        trigger_error('Unknown server; please modify config file');
}
?>

PRODUCTION_SERVER and DEVELOPMENT_SERVER can be defined in each server's auto-prepend file; see:

http://www.php.net/ini.core#ini.auto-prepend-file


_______________________________________________
macports-users mailing list
macports-users@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macports-users

Reply via email to