I have this weird issue with apache:
$ apachectl configtest
Syntax OK
Configs are ok, and it was actually working a minute ago, before I shut it down.
$ sudo apachectl start
org.apache.httpd: Already loaded
No it's not:
$ ps ax | grep httpd
58204 s000 R+ 0:00.00 grep httpd
Let's try to stop it:
$ sudo apachectl stop
Looks like it is stopped, right? Let's try to start it again:
$ sudo apachectl start
$ sudo apachectl start
org.apache.httpd: Already loaded
So it must be running but it's not in ps ax
and it simply doesn't work.
$ sudo apachectl stop
$ sudo apachectl stop
launchctl: Error unloading: org.apache.httpd
Tried to remove it from autostart:
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
launchctl: Error unloading: org.apache.httpd
But it's the same when I try to launch it, it pretends that it starts but it doesn't. Nothing in error log either. Help!
OS X 10.8.2 Mountain Lion
Update:
After reboot:
$ sudo apachectl start
Password:
org.apache.httpd: Already loaded
$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
org.apache.httpd: Already loaded
$ ps ax | grep httpd
7300 s000 R+ 0:00.00 grep httpd
So I am effectively left without a web-server now.
Solution:
After a study of org.apache.httpd.plist
I figured out that apache is controlled by a ruby script /usr/sbin/http-wrapper
which had some issues running because I had replaced the system ruby interpreter. This fixed it for me:
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
How do I restart httpd service? You can use the service or systemctl command to restart httpd server. Another option is use /etc/init. d/httpd service script under Linux or Unix-like systems.
You can also stop httpd using /sbin/service httpd stop. The restart option is a shorthand way of stopping and then starting the Apache HTTP Server. Apache will display a message on the console or in the ErrorLog if it encounters an error while starting.
run the server manually and fix the error reported:
root#> /usr/sbin/httpd -k start
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With