$PATH environment variable for apache2 on mac
You can set the PATH environment variable in /System/Library/LaunchDaemons/org.apache.httpd.plist
.
More in the docs.
Changing the Homebrew Apache PATH variable
I found the answer here.
To change Apache environment variables when Apache was installed with Homebrew, edit the homebrew.mxcl.httpd24.plist file located in /usr/local/Cellar/httpd24/your version of Apache/.
<?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>
Then restart Apache.
how to set env variable for apache on Mac OS X
Here is what was wrong. In one of the virtual host i has typo and it started with #. The http.conf has server-root configuration which says
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk. If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr"
It was terrible typo mstake.
How do I add paths to the Apache PATH variable?
That seems awfully strange to me that you are trying to set the PATH from within Apache. Instead, you should be setting the PATH for your system. There are several ways to do this in Mac OS X:
User-specific
For a single user, you can edit ~/.profile and add:
export PATH="$PATH":/opt/local/lib/mysql5/bin:/this-is-a-test
Or you can create/edit ~/.MacOSX/environment.plist and define the PATH that way.
System-wide
On newer versions of Mac OS X, there is a file named "/etc/paths" and there is a folder named "/etc/paths.d" that allow you to extend the default paths. Basically, you would create a file in "/etc/paths.d" that lists all the paths that you wish to add to the default paths. On versions of Mac OS X that do not support this (you can tell based on whether "/usr/libexec/path_helper" exists), one can edit the default paths for all users by placing the export statement above in /etc/profile.
Change PATH Environment Variable in MAMP
In MAMP 4.0.6 for OSX I was able to update the Apache Environment Path by doing the following:
First check /Applications/MAMP/Library/bin/apachectl
for a line with the comment:
#pick up any necessary environment variables
Just below this line you should see a path to where MAMP will load environment variables.
Mine said:
/Applications/MAMP/Library/bin/envvars
In the /Applications/MAMP/Library/bin
path you should see a file named envvars_
.
Copy this file and rename to envvars
and add the following line:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
Now restart your MAMP servers. The phpinfo should now have the updated path information.
Set ENV PATH of php and ffmpeg to use it inside PHP scripts with CLI like shell_exec()
You may put environment variables in the command just like in shell.
Examples:
shell_exec('PATH=/usr/local/bin:/usr/local/opt/php55/bin:$PATH which ffmpeg');
Alternative solution:
In case you do not want to make the code dirty, you may configure your Apache environment variables as follow.
Mac:
Edit
/System/Library/LaunchDaemons/org.apache.httpd.plist
and added
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/local/opt/php55/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
(answer copied from $PATH environment variable for apache2 on mac)
Other platforms: (for your references)
https://serverfault.com/questions/151328/setting-apache2-path-environment-variable
Related Topics
Change Name of Laravel's Created_At and Updated_At
Php: Catch Exception and Continue Execution, Is It Possible
Group Array Values Based on Key in PHP
Single Session Login in Laravel
How to Match Accented Characters with PHP Preg
Codeigniter: 404 Page Not Found on Live Server
Secure and Flexible Cross-Domain Sessions
Fatal Error: Class 'Mongodb\Driver\Manager' Not Found
How to Round to Nearest Thousand
How to Install an Older Version of PHPunit Through Pear
Php: How to Generate a Hmacsha256 Signature of a String
How to Check If Directory Contents Has Changed with PHP
How to Search Through a JSON Array in PHP
Facebook API/PHP - How to Change a User's Profile Image via Fb Graph API