I'm trying to install zend server on mac and need to uninstall the apache server that is auto included with Mavericks so that the Apache server included with Zend is used instead. Can it be prevented from running on startup or permanently removed?
问题:
回答1:
Try this:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
This will stop a running instance of Apache, and record that it should not be restarted. It records your preference in /private/var/db/launchd.db/com.apple.launchd/overrides.plist
.
回答2:
try this
sudo killall httpd
it will stop all
回答3:
If you got to this page as I did and was getting something like /System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service.
try NOT using the sudo command, which was making me get the above error.
回答4:
I ran into this same problem, and the culprit was pretty obtuse. It wound up that OSX was attempting to include a nonexistent php version, however the OSX httpd was also not directly accessible due to the homebrew httpd taking priority. Here's what I did that fixed it:
First: brew unlink httpd
Then which httpd
revealed the following: /usr/sbin/httpd
At this point I ran sudo /usr/sbin/httpd -k stop
, and the real culprit revealed itself:
httpd: Syntax error on line 527 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+php-osx.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _environ\n Referenced from: /usr/local/php5/libphp5.so\n Expected in: /usr/sbin/httpd\n in /usr/local/php5/libphp5.so
I then fixed this with sudo vi /private/etc/apache2/httpd.conf
, and commented out all of the lines in that file, and ran the following for good measure:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
This stated:
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
The underlying problem was that the native OSX instance was still running, but had become detached from launchctl
due to the PHP not found issue. So basically launchctl
thought it had properly shut the process down, but the apachectl
agent refused to stop due to the PHP error, resulting in a decoupled process, which was only accessible for direct control when the homebrew version was also unlinked.
Commenting out the native PHP include allowed me to run sudo apachectl -k stop
without issue.
After sorting this out, I then ran
brew link httpd
followed by
brew services restart httpd
Profit.