44

Is there a way to make apache and mysql not run automatically on startup?

Currently, whenever I boot my machine, they start automatically and run in the background.

I am using Ubuntu 12.04.

T0xicCode
  • 347
  • 5
  • 15
shubham
  • 661
  • 1
  • 7
  • 12

3 Answers3

47

Apache

sudo update-rc.d -f apache2 disable

Apache is still using rc.d init script, which is why you must disable it using update-rc.d.

MySQL

echo manual | sudo tee /etc/init/mysql.override

MySQL on the other hand has converted to an upstart configuration file. The recommended way of disabling upstart services is to use an override file.

T0xicCode
  • 347
  • 5
  • 15
SirCharlo
  • 39,016
  • 10
  • 75
  • 82
  • Do i have to do this on every startup – shubham May 17 '12 at 16:51
  • Nope, only once.. The changes are persistent. :) – SirCharlo May 17 '12 at 16:52
  • 11
    A cleanest way to disable autostart for any service with a `.conf` file in `/etc/init` (like mysql), is to run as root: `echo "manual" >> /etc/init/[service_name].override`. – el.atomo Nov 23 '12 at 10:41
  • kudo @el.atomo [Manpage](http://manpages.ubuntu.com/manpages/natty/man5/init.5.html) **Event Definition** *"manual" This stanza will disregard any previously seen **start on** definition. By adding this stanza on any line below the **start on** definition, it provides the ability to stop a job from being automatically started. When specified, the only way to start such a job is via **start***. -- Also, take a look at **Override File Handling** *Override files allow a jobs environment to be changed without modifying the jobs configuration file.* – Gerard Roche Dec 06 '12 at 19:56
  • Also this will work too: `sudo mv /etc/init/cups.conf /etc/cups.conf.disabled`. It's easier to see what services are disabled when you do this. Re: [Can you remove printer support (cups)](http://askubuntu.com/questions/97666/can-you-remove-printer-scaner-support) – Gerard Roche Dec 07 '12 at 11:40
  • Can you use `update-rc.d` on MySQL? – Ehtesh Choudhury Feb 04 '14 at 18:56
  • @Shurane Sadly, no. – SirCharlo Feb 11 '14 at 12:20
  • it seems to me that mysql only starts with apache by default, so I only need to disable apache. – törzsmókus Apr 22 '16 at 01:23
10

For all system services in /etc/init.d, disabling them can be done with the update-rc.d command, e.g.:

update-rc.d -f apache2 remove

To restore it to running on startup:

update-rc.d apache2 defaults

You can also manually start and stop via service apache2 start and service apache2 stop.

Mattie
  • 534
  • 3
  • 12
5

Run the following in a terminal:

update-rc.d -f apache2 remove

update-rc.d -f mysql remove

see: http://www.aboutlinux.info/2006/04/enabling-and-disabling-services-during_01.html

MCR
  • 321
  • 1
  • 3