Page 1 of 1

Setting Apache and MySQL to start/shutdown manually

Posted: Sun Jan 15, 2012 2:20 pm
by klem77
Hi,

I usually use Apache+PHP+MySQL on Windows. There I set both Apache and MySQL as manually started services, so they only up and running (hence consume resources) when I actually use them. AFAIK both defaults to start on system start and only shutdown on system shutdown. Can I achieve the same setup like on Windows in Mint? How?

Thanks

Re: Setting Apache and MySQL to start/shutdown manually

Posted: Sun Jan 15, 2012 3:31 pm
by xenopeek
Starting Apache and MySQL will take some additional time, but other than that if you give these services nothing to do they won't impact your system performance (they won't eat much CPU in idle; and any memory they need goes to swap). However, and you can probably do this through the GUI as well, here goes with a few commands to switch them to manual.

List all the services on your machine:

Code: Select all

initctl list
Look for the apache and mysql service name. Once you have the correct name for the apache and mysql service from that list, switch each service to manual with the following command (replace <servicename>, including the angle brackets, with the service name from the list):

Code: Select all

 echo manual | sudo tee -a /etc/init/<servicename>.override
After reboot those services will not start automatically. You can start them with:

Code: Select all

sudo initctl start <servicename>

Re: Setting Apache and MySQL to start/shutdown manually

Posted: Fri Jan 20, 2012 6:35 am
by klem77
Thanks for the info.

I was thinking to write a shell script to start/stop those services. I note that each time I 'sudo' Mint ask for password. Are there any command that lets me set an elevated privilege once, do multiple things at that privilege, then return to normal privilege?

Re: Setting Apache and MySQL to start/shutdown manually

Posted: Fri Jan 20, 2012 6:51 am
by xenopeek
You can just sudo the shell :wink: To run a shell as superuser:

Code: Select all

sudo bash
Any commands can be run now without sudo. Type exit to return to normal shell.

Or you can just login as root:

Code: Select all

sudo -i