
Note the following perl script
#!/usr/bin/env perl -wT
print "Content-type: text/html\n\n";
#
foreach $key (sort keys(%ENV)) {
print "$key = $ENV{$key}<p>";
}
As you can see the hash bang is #!/usr/bin/env perl this is supposed to be more portable because it will find the first instance of perl in your path so if you put /usr/local/bin first in the PATH you get your Homebrew installed Perl
The problem is the above script wouldn't find the Homebrew Perl because my Homebrew Apache 2.4 PATH was PATH = /usr/bin:/bin:/usr/sbin:/sbin
This wouldn't be a problem except I had installed JSON, Config::Simple and other Perl modules in the Homebrew Perl under /usr/local and when I ran the CGI script that used these against the above default PATH they were erroing out with and @INC error because of not finding the Perl modules under the system Perl in /usr/bin/perl
It took me a while of Googling to find out how to configure the plist file to pass a new environment in but here it is. I hope it saves someone 2 hours.
So firstly shut your httpd24 down
brew services stop httpd24
edit your homebrew.mxcl.httpd24.plist file and add the EnvironmentVariables key and the following <dict> to it
vim /usr/local/Cellar/httpd24/2.4.23_2/homebrew.mxcl.httpd24.plist
restart your httpd
brew services stop httpd24
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.httpd24</string>
<!-- add this -->
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin</string>
</dict>
<!-- end add -->
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/httpd24/bin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
b

0 Comments