Apache, the MySQL, Andrew Mac after uninstalled standard Home When Apache (e) of Stop the occurrence of an error

Asked 2 years ago, Updated 2 years ago, 99 views

Mac OS: Sierra

After installing PHP, Apache, and Mysql on the Mac, I uninstalled Apache, MySQL, and Homebrew because http://localhost cannot be displayed in my browser.

In addition, considering that Apache, the standard Mac, may be in the way,

 sudo apachectl stop

When I ran , I received the following error:

/System/Library/LaunchDaemons/org.apache.httpd.plist:Could not find specified service

After this,

$sudo apachectl start

Then, there was no error.

$sudo apachectl stop

I think it's done.

$which Apachectl
/usr/sbin/apachectl

Questions to ask:

1) I would like to know the cause of the error when I stopped Apache and how to deal with it.
2) How to prevent the Mac standard Apache from starting automatically (this is the code below)
sudo launchctl unload-w/System/Library/LaunchDaemons/org.apache.httpd.plist

The above error occurred when
Please tell me the cause and how to deal with it.

I'm a beginner, so it would be very helpful if you could tell me exactly what to do.
(I've learned a lot of things while dealing with it, but I'm still confused...)

The purpose of this is to prevent Apache from running on the Mac standard when you install Apache on Homebrew.

macos apache

2022-09-30 21:25

1 Answers

I would like to know the cause of the error when I stopped Apache and how to deal with it.

This is probably because Apache, the Mac standard, was not originally started.Based on the results of the experiment with macOS Sierra at hand...

Launch #Apache
$ sudo apachectl start

# Verify Apache Has Been Started
$ sudo launchctl list | grep httpd
53290 org.apache.httpd

# stop
$ sudo apachectl stop

# Verify Stopped
$ sudo launchctl list | grep httpd

# try to stop again
$ sudo apachectl stop
/System/Library/LaunchDaemons/org.apache.httpd.plist—Could not find specified service

"As a countermeasure, I think ""do nothing"" is ok."

sudo launchctl unload-w/System/Library/LaunchDaemons/org.apache.httpd.plist
The above error also occurred

when

This is the same cause and action as sudo apachectl stop.This is because the apachectl command calls launchctl on the back with the same argument as above.

 Find out where the #apachectl entity is
$ which apachectl
/usr/sbin/apachectl

# find out what apachectl is actually doing
$ less apachectl
# Read scripts while scrolling through ctrl-v, option-v, ctrl-n, ctrl-p, etc.

It's relevant here:

 stop | graceful-stop)
    run_launchctl unload-w$LAUNCHD_JOB
    ERROR = $?
    ;;

For stop, we call the function run_launchctl with the argument unload-w$LAUNCHHD_JOB, where run_launchctl is defined above and

run_launchctl(){
    if [$UID!=0]; then
        echo This operation requirements root.
        exit1
    fi

    $LAUNCHCTL$@
}

After checking if it is running with root privileges, you have passed all arguments to the commands specified in the LAUNCHCTL variable.LAUNCHCTL and LAUNCHD_JOB are further defined above and

LAUNCHCTL="/bin/launchctl"
LAUNCHD_JOB="/System/Library/LaunchDaemons/org.apache.httpd.plist"

To sum up to this point, sudo apachectl stop will eventually execute the following command:

/bin/launchctl unload-w/System/Library/LaunchDaemons/org.apache.httpd.plist


2022-09-30 21:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.