I use Mac OS X and use Launchd to automatically start XAMPP. I have set the apache user set to be the same as my account name in httpd.conf
User cwd Group nogroup
Well, if I just let the computer start up, and if I run a php script with these commands, here is what I get:
echo exec('whoami'); //cwd exec('echo 1234 | pbcopy'); echo exec('pbpaste'); // (nothing)
However, if I stop XAMPP and restart it (using XAMPP Control), then it works as expected and the third line's result is 1234.
echo exec('pbpaste'); // 1234
I also have similar experiences with running other system commands with exec
or shell_exec
like ssh
. They don't seem to work until I manually restart apache. Does anyone have anythoughts on this?
Here is my launch config file:
/Library/LaunchDaemons/xampp.sql.startapache.plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>EnableTransactions</key> <true/> <key>Label</key> <string>xampp.startapache.mysql</string> <key>ProgramArguments</key> <array> <string>/Applications/XAMPP/xamppfiles/xampp</string> <string>startmysql</string> </array> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>/Applications/XAMPP/xamppfiles</string> <key>KeepAlive</key> <false/> <key>AbandonProcessGroup</key> <true/> </dict> </plist>