I installed nginx on my mac lion by using homebrew. When i type command:
nginx -s stop
the service is launched again in a second. how can i stop it?
If you installed the LaunchAgent, I believe that will keep the service alive if it's not running.
See launchd.plist man page
You can try running launchctl stop org.nginx.nginx or remove the
<key>KeeyAlive</key>
<true/>
bit from the plist (~/Library/LaunchAgents/org.nginx.nginx.plist)
Update
Looks like the only way to stop the daemon is to unload the LaunchAgent:
launchctl unload ~/Library/LaunchAgents/org.nginx.nginx.plist
/usr/local/opt/nginx/bin/nginx -g daemon off
Related
I'm running Mojave on a Mac Pro. Prior to this version of the OS I used Apple's Server app to manage Apache/httpd. Now I can't seem to permanently kill or stop httpd. Something keeps it alive and restarts it even when I do the following as root...
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
apachectl stop
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
apachectl -k stop
httpd (no pid file) not running
If I 'killall httpd' it just comes back. If I kill the main root httpd process in Activity Monitor, it comes right back. Restart the computer, it's still running.
I just want to permanently kill httpd so I can do an alternate installation, possibly with brew or on another machine. I don't want it running and I don't understand what keeps relaunching httpd on me.
The command you mentioned first works for me. I just added 'sudo'
local:~ mac$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
The solution explained in Answer 1 did not work for me when Mojave server.app was installed.
I had to use this:
sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.serviceproxy.plist
I want to set up local web server using Apache and PHP on my Mac running Sierra. I followed this tutorial:
https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions
And I am stuck at changing the document root from httpd.config, for whatever reason this change does not take effect at all. If I type http://localhost it still says "It works", it still uses the original html file.
Another weird thing is that apparently I can't stop apache at all. I tried running
$ sudo apachectl stop
but I still can’t access http://localhost
if I run
$ brew services list
httpd24 is stopped. What gives? What am I doing wrong?
There is an instance of apache pre-installed with macOS. So you have now two versions of apache installed. If you check:
which apachectl
you will probably obtain:
/usr/sbin/apachectl
which is the official macOS version of apachectl. Stop it with:
sudo apachectl stop
Disable the auto-loading of the pre-installed apache with (as explained in the tutorial you mentioned):
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
To run the homebrew version do:
brew services run httpd24
to stop it:
brew services stop httpd24
to register it to launch at login:
brew services start httpd24
I ran sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist and it unloads apache. But when I reboot, apache is back up and running. How do I permanently remove Apache from starting on boot?
Apparently I need to study the manual. It needs the -w flag to override the Disabled key as found in the man page for launchctl
I am using Mac OS X 10.7.3. I installed tomcat6 via macports 2.0.4. I put the tomcat6 location in myeclipse for spring 10 server configuration. Everything was fine so far.
Then I tried to start it in myeclipse. It could not start, saying something like 8080 port is already in use.
Then I went to terminal.
ps aux | grep tomcat
4 process showed up. It seemed tomcat6 started automatically after the installation. Then I tried to stop it with
sudo tomcatctl stop
Here came the problem. No matter how I tried, it always says
Stopping Tomcat...(pid ****)............... giving up.
I tried to kill the process but it kept starting tomcat again right after the kill.
How do I stop it and let myeclipse take over it? Any help is appreciated.
Thanks,
Milo
try doing sudo port unload tomcat6
This command replaced interacting with launchctl yourself, but im unsure if it supports a -w switch which would typically remove the launch daemon were it used with launchctl unload meaning you wouldnt run into the magic restart problem.
I have memcached installed via homebrew.
how do I start/stop the server?
Any command-line tools to interact with memcached?
does homebrew have a way of removing a package?
When you installed it, it put a file named homebrew.mxcl.memcached.plist in /usr/local/Cellar/memcached/$version/; you copy that file into ~/Library/LaunchAgents and then tell launchd to start it with launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist.
If you were watching the console carefully during the brew install command, it should have said something about doing these exact steps. If you run brew info it'll re-print this information, e.g. brew info memcached.
You should probably read https://docs.brew.sh/Manpage -- it has more useful documentation including the brew remove command which will remove the package if you decide you don't want it.
Brew used to have a command brew services (https://thoughtbot.com/blog/starting-and-stopping-background-services-with-homebrew), now deprecated. Instead, to get always-correct advice, run this command:
brew info memcached
Via telnet: telnet localhost 11211
See also What are some useful tips/tools for monitoring/tuning memcached health?
brew remove memcached
Additionally you can run "brew info", if you have forgotten about the instructions.
→ brew info memcached
memcached 1.4.7
http://memcached.org/
Depends on: libevent
/usr/local/Cellar/memcached/1.4.6 (8 files, 156K)
You can enable memcached to automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/memcached/1.4.7/com.danga.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist
Or start it manually:
/usr/local/bin/memcached
Add "-d" to start it as a daemon.
http://github.com/mxcl/homebrew/commits/master/Library/Formula/memcached.rb
To restart:
If you have the memcached starting up with launchd and your plist file has
<key>KeepAlive</key>
<true/>
Then you can just kill the process and it will reboot automagically.
ps ux | grep memcached
pkill -f memcached
ps ux | grep memcached
To stop launchd from restarting automatically:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
To add memcached to launchd again:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
To uninstall something installed by homebrew:
brew uninstall memcached
And you can also create aliases
alias memcached-start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached-stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached-restart="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist;launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
and after that you cant easy start/stop/restart memcached
memcached-start
memcached-stop
memcached-restart
You can also use Lunchy to set the start/stop. Lunchy is a wrapper written over launchctl. I’ve written a detailed post about this.
$ gem install lunchy
$ mkdir ~/Library/LaunchAgents
$ cp /usr/local/Cellar/memcached/$version/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
To start memcached
$ lunchy start memcached
To stop memcahed
$ lunchy stop memcached
You can enable Memcached to automatically load on login.
This first line creates a symlink (symbolic link) from where Homebrew installed it to the LaunchAgents folder.
ln -sfv /usr/local/Cellar/memcached/1.4.17/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
Then to launch it now:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist