Ubuntu: How to exclude LAMP from startup in 16.04



Question:

Regarding the following command and result:

$ systemd-analyze blame | grep -P '(mysql|php|apache)'           12.936s mysql.service            8.815s php7.0-fpm.service            6.515s apache2.service  

I want to remove LAMP from startup so my system boot faster. Since I don't use LAMP all the time, I would prefer to run them whenever I need rather than keeping them running all the time, especially during boot.

I have checked some other questions here (including How to stop mysql from running at boot time? and how to stop apache2, mysql from starting automatically as computer starts? both asked in 2011) But all of them are old.

Is there any difference between using those method and the way it should be done in 16.04? (the reason I ask this question is as far as I know, Ubuntu has moved towards Systemd which was not the case at 2011!)

Thanks


Solution:1

You can use the new utility called systemctl. Note: these commands are expected to be run under root privileges.

From Fedora 15 Deployment Guide (Fedora 15 has introduced systemd):

7.1.2. Disabling the Service

To disable starting a service at boot time, use the systemctl command in the following form:

systemctl disable service_name.service

The next time you boot the system, the service will not be started. For information on how to stop the service immediately, refer to Section 7.2.3, “Stopping the Service”.

...

7.2.3. Stopping the Service

To stop a service, use the systemctl command in the following form:

systemctl stop service_name.service

This will stop the service in the current session. To disable starting the service at boot time, refer to Section 7.1.1, “Enabling the Service”.

To disable starting the LAMP server at boot time, use this command:

systemctl disable mysql.service php7.0-fpm.service apache2.service  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »