-
Edit the Apache2 plist file with whatever editor you like (example using vim):
$ sudo vim /System/Library/LaunchDaemons/org.apache.httpd.plist
-
Add the following to the the plist file:
<key>EnvironmentVariables</key> <dict> <key>PATH</key> <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string> </dict>
-
Restart Apache2
$ sudo /usr/sbin/apachectl stop $ sudo /usr/sbin/apachectl start
Last active
April 27, 2022 12:56
-
-
Save srayhunter/5208619 to your computer and use it in GitHub Desktop.
Configure Apache on Mac OSX with Environment Variables
I'm getting the same issue.
Solution: For my case (same than SubhajitSarkar)
I have put the environment variables in the ~/.profile (I'm using zsh on M1)
brew install httpd # run as non-root user on port 8080
...
nano ~/.profile
...
export MY_VAR="test"
...
source ~/.profile
apachectl stop
apachectl start
# php 8.x code
...
echo getenv('MY_VAR')
...
Output: test
And now it is working properly on Monterrey.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In catalina I had to mount the root to read/write using
sudo mount -uw /
after disable csrutil.