Apachectl “service already loaded” when it's n

2019-07-04 00:54发布

问题:

I am trying to learn a bit about the terminal and servers. I am following a course and in this course it states that you can start and stop the server apache (on mac) by using the command:

sudo apachectl start

But, when I do this, it comes back with a message saying that apache is already functioning. The full message:

/System/Library/LaunchDaemons/org.apache.httpd.plist: service already loaded

Apache is clearly not running though:

ps aux | grep httpd

doesn't return any activity.

I expect this is something to do with the fact that the course I am following is for Yosemite and I am running El Capitan. I don't know much about the issue and I am trying to learn, but I can't even follow the course if I can't even start the server.

Can anyone help?

Thanks,

P

edit ---------------------------------------------------------------------

<?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>Disabled</key>
        <true/>
        <key>Label</key>
        <string>org.apache.httpd</string>
        <key>EnvironmentVariables</key>
        <dict>
                <key>XPC_SERVICES_UNAVAILABLE</key>
                <string>1</string>
        </dict>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/httpd-wrapper</string>
                <string>-D</string>
                <string>FOREGROUND</string>
        </array>
        <key>OnDemand</key>
        <false/>
</dict>
</plist>

回答1:

It's likely to be a config error. Run the following and fix any errors

sudo apachectl configtest


回答2:

Try

apachectl status

This is probably the best way to check the status of Apache.



回答3:

Can you try the below

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo apachectl stop
sudo apachectl start