37

My os is 11.04.

I have apache2 & mysql installed.

How to stop apache2, mysql from starting automatically as computer starts?

Tim
  • 32,861
  • 27
  • 118
  • 178

7 Answers7

51

MySQL is handled by upstart. In 11.04 you can use the new override feature to modify the starting behaviour:

echo "manual" >> /etc/init/mysql.override

See the section "Disabling a Job from Automatically Starting" in the Upstart Cookbook

Apache still uses traditional SysV init scripts so you use

 update-rc.d -f apache2 remove

to remove the links from /etc/rcX.d or, alternatively, use

 update-rc.d apache2 disable

which "disables" the script by changing it from a start script S91apache2 to a stop script K09apache2. This is reversible by update-rc.d apache2 enable.

15

Interestingly, it's a different answer for each package in 11.04.

  • apache2 uses System V style init scripts. To disable it from boot:
    sudo update-rc.d -f apache2 remove
  • However, mysql uses an Upstart job, to disable it, create an "override" file:
    echo "manual" | sudo tee /etc/init/mysql.override

To learn more about override files, see: The Upstart Cookbook

Mark Russell
  • 7,376
3

This thread will help you: https://superuser.com/questions/35151/how-do-i-stop-services-from-starting-on-boot-on-ubuntu

vinni_f
  • 203
  • This only works for services using SysV style init scripts. Ubuntu is switching to Upstart for most services so update-rc.d doesn't work anymore. – Florian Diesch May 04 '11 at 17:37
1

With heavy adoption of systemd as system manager and init system for debian based distributions like ubuntu , we can now use systemctl commands to prevent a service from automatically starting at boot.

for example :

sudo systemctl disable apache2

To start using it when required , you can use:

sudo systemctl start apache2

To stop using it, you can use:

sudo systemctl stop apache2

And to see if it's running or not , you can use :

sudo systemctl status apache2

r4k3sh
  • 23
1

update-rc.d is a good CLI tool to do this. The linked page has an example involving apache2

cqcallaw
  • 1,113
1

It was't working for me. When trying to disable mysql in ubuntu I was receiving the message:

System start/stop links for /etc/init.d/mysql do not exist.

So I found a work around in this link: http://forum.linode.com/viewtopic.php?t=5594

sudo mkdir /etc/init.disabled

sudo mv /etc/init/mysql.conf /etc/init.disabled/

And that's it.

barbolo
  • 213
  • 1
  • 2
  • 7
0

use rcconf to enable/disable a service to auto run on boot.

sudo apt-get install rcconf

Now, type sudo rcconf

And you will see list of services that are installed on your Ubuntu machine. Those marked with star are auto run during boot process. To disable Apache, MySql just navigate to it using arrows and press space bar. Then navigate to OK button using Tab key and again press Space to save configuration.

hKedia
  • 1