How do I stop Apache2 from automatically starting on boot? I can't seem to find an option that disables the automatic start-up when I turn on the machine.
4 Answers
you could simply disable it by:
sudo update-rc.d apache2 disable
and then if you would like to enable it again:
sudo update-rc.d apache2 enable
depending on the project i am working on, it is handy to have the service conveniently available, if i wish to re-enable it.
-
4
enable
gave me an error likerunlevel arguments (none) do not match LSB Default-Start values
, butsudo update-rc.d apache2 defaults
appears to have re-enabled it successfully.– hereCommented Jan 13, 2014 at 3:58 -
2@here
sudo update-rc.d apache2 enable
played as expected for me Commented Feb 9, 2014 at 15:12 -
1On Ubuntu Trusty it tells me "The disable|enable API is not stable and might change in the future."– TannerCommented Jun 10, 2014 at 0:31
-
1Doesn't work -
error: no runlevel symlinks to modify, aborting!
. However, apache2 is running and autostarts.– DanielCommented Dec 14, 2014 at 11:05 -
Doesn't work anymore:
update-rc.d: error: no runlevel symlinks to modify, aborting!
– TomDoggCommented Apr 29, 2015 at 9:33
On old,pre systemd distributions under /etc/init.d/
you will find all the init scripts for different boot up services, like apache2, networking, etc.
Depending on which runlevel the computer starts in, different services are started.
So from the /etc/init.d/
folder each "service" is linked to one/many/no run level folders named from rc0.d
to rc6.d
.
To keep things simple there is a tool for removing/adding these links, hence removing or adding scripts to and from start up.
To disable apache2 simply type:
sudo update-rc.d apache2 disable
This disables apache2 at startup but is not removed so it can be enabled again. To remove the apache2 startup scripts do the following:
To remove apache2 simply type:
sudo update-rc.d -f apache2 remove
###Doing this will cause all runlevel folders that are linked to apache2 to be removed.
-
2
-
Doesn't work anymore:
The script you are attempting to invoke has been converted to an Upstart job, but lsb-header is not supported for Upstart jobs. (...)
– TomDoggCommented Apr 29, 2015 at 9:34 -
2@TomDogg, can you specify the versions you were working with? This answer works for Apache 2 on Ubuntu 14.04.3 Commented Nov 2, 2015 at 20:20
-
1
-
12Warning! This will REMOVE the service! Use
sudo update-rc.d apache2 disable
. Commented Jan 17, 2017 at 19:37
With systemd
we can now use systemctl
commands to prevent a service from automatically starting at boot.
here is an example:
sudo systemctl disable apache2
You will still be able to start and stop the service but it won't start up at boot.
-
2Linux Mint is still based on Ubuntu 14.04. Ubuntu starts using systemd from 15.04 on.– twan163Commented Dec 6, 2015 at 23:01
-
1@dragonmnl as twan163 said, systemd is for the newer versions (debian jessie or equivalent +)– mchidCommented Dec 8, 2015 at 21:55
-
1
-
1
-
1If encounter
update-rc.d: error: no runlevel symlinks to modify, aborting!
, recreate any below missing simlinks; then retry: /etc/rc0.d/K01<service> /etc/rc1.d/K01<service> /etc/rc2.d/S99<service> /etc/rc3.d/S99<service> /etc/rc4.d/S99<service> /etc/rc5.d/S99<service> /etc/rc6.d/K01<service> Commented Aug 11, 2018 at 2:26
Thought I'd just add to the answers by @gsullins and @tomodachi, for future readers who used the accepted answer.
If you've already used:
sudo update-rc.d apache2 remove
You can use the argument defaults
to add apache2 back into the autostart
sudo update-rc.d apache2 defaults
Then you're able to enable/disable
sudo update-rc.d apache2 disable
sudo update-rc.d apache2 enable
update-rc.d
has filled this void.