Operating system: Ubuntu12.04
Hardware environment: HP CQ45
After the user installs Apache and MySQL using the sudo apt-get install, these services are started by default, but sometimes need to turn off the boot of these services.
First, popularize a concept, the following transfer from Wikipedia:
runlevel (Runlevel) refers to different operating modes under UNIX or UNIX-like Linux operating systems. The runlevel is usually divided into 7, ranging from 0 to 6, but can be more if necessary.
For example, under most Linux operating systems, there are 6 typical operating levels:
- 0 Downtime
- 1 single user, Does not configure network interfaces, start Daemons, or allow non-root logins
- 2 Multi-user, no network connection Does not configure network interfaces or start daemons
- More than 3 users, start the network connection starts the system normally.
- 4 User definable
- 5 multi-user with graphical interface
- 6 restart
In Debian Linux 2-5 of these four runlevel are concentrated on level 2. This level is also the normal operating level of the system preset.
(Note: For these runlevel we don't have to be too tangled with what that means, just know that in Debian/ubuntu (Ubuntu is the branch of Debian) Linux is enabled by default at level (Runlevel) 2)
In Debian Linux, the following paths correspond to different runlevel. When the system starts, the corresponding service is started through the script file.
- /ETC/RC0.D Run Level 0
- /ETC/RC1.D Run Level 1
- /ETC/RC2.D Run Level 2
- /ETC/RC3.D Run Level 3
- /ETC/RC4.D Run Level 4
- /ETC/RC5.D Run Level 5
- /ETC/RC6.D Run Level 6
Below we go to the/etc/directory to find these directories, enter in the terminal:
[Email protected]-Compaq-Presario-CQ45-Notebook-Pc:~$ ls/etc/Rc*
/etc/Rc.Local
/etc/Rc0.D:
K09apache2K20winbind S30urandom S40umountfs
k10unattended-Upgrades README S31umountnfs.SH s60umountroot
K20speech-Dispatcher S20sendsigs s35networking S90halt
/etc/Rc1.D:
K09apache2K20kerneloops K20winbind S70dns-Clean
K15pulseaudio k20saned README S70PPPD-Dns
K20acpi-Support K20speech-Dispatcher S30killprocs S90single
/etc/Rc2.D:
README S50pulseaudio S70PPPD-DNS S99grub-Common
S20kerneloops S50rsync S75sudo S99ondemand
S20speech-Dispatcher s50sanedS91apache2S99rc.Local
S20winbind S70dns-Clean S99ACPI-Support
/etc/Rc3.D:
README S50pulseaudio S70PPPD-DNS S99grub-Common
S20kerneloops S50rsync S75sudo S99ondemand
S20speech-Dispatcher s50sanedS91apache2S99rc.Local
S20winbind S70dns-Clean S99ACPI-Support
/etc/Rc4.D:
README S50pulseaudio S70PPPD-DNS S99grub-Common
S20kerneloops S50rsync S75sudo S99ondemand
S20speech-Dispatcher s50sanedS91apache2S99rc.Local
S20winbind S70dns-Clean S99ACPI-Support
/etc/Tcs.D:
README S50pulseaudio S70PPPD-DNS S99grub-Common
S20kerneloops S50rsync S75sudo S99ondemand
S20speech-Dispatcher s50sanedS91apache2S99rc.Local
S20winbind S70dns-Clean S99ACPI-Support
/etc/Tcp.D:
K09apache2 K20winbind s30urandom s40umountfs
k10unattended-upgrades readme S31umountnfs sh s60umountroot
k20speech-
/etc/rcs.:
readme s25brltty s37apparmor s55urandom S70x11< Span class= "pun" >-common
The color-coded content in the code is a file related to the Apache service and can be seen in rc1.d rc6.d for K09apache2, rc2.d rc3.d rc4.d RC5.D in the S91apache2, the following brief introduction of K09apache2 and s91apache2 meaning:
For files beginning with K, the system terminates the corresponding service;
For files beginning with S, the system will start the corresponding service;
Now for Debian/ubuntu Linux to start the process you should have some understanding, summed up:
The/ETC/RC0.D~RC6.D directory is stored in the 0~6 run at the runtime to start the service related files, because Ubuntu by default in RunLevel 2 boot, then we need to modify the files in the RC2.D, thus prohibiting the Apache service to start. Reviewing the files in the/ETC/RC2.D directory, you can find that apache2 related files are s91apache2, and the system will start the corresponding service by simply introducing the files that begin with S. So what we're going to do is change the s91apache2 to k******, but we don't know how much to change, here we need to manage with a management tool, namely sysv-rc-conf.
Installs with Apt-get under Ubuntu, very simple
[Email protected] -Compaq-Presario-CQ45-Notebook-PC:/etc$ sudo apt- Get Install SysV-RC-conf
Next Open sysv-rc-conf
[Email protected] -Compaq-Presario-CQ45-Notebook-PC:/etc$ sudo sysv- RC-conf
(Note: Because there is a need to modify the system-related content, you need to use sudo, that is, root permission to open)
The configuration interface is simple and straightforward:
The first line of service is followed by the RunLevel, with 1,2,3,4,5,0,6,s, which basically conforms to the RunLevel described earlier, and the last one does not introduce
The figure of the X is to run in the corresponding runlevel when the start-up service, here we can see apache2 in runlevel2,3,4,5 are boot-up, corresponding to the previous/etc/rc2.d~/etc/ RC5.D directory is a s91apache2 file, again verify the previous content, move the cursor to the 2nd column of Apache2 row, press space to reverse the startup item
Press Q to exit after configuration is complete. Now let's take a look at the contents of the/etc/rc2.d/directory:
Hp@hp-Compaq-Presario-CQ45-Notebook-Pc:/etc$ LS/etc/Rc2.D/
K09apache2S20winbind S70dns-Cleans99grub-Common
README s50pulseaudio s70pppd-DNS S99ondemand
S20kerneloops s50rsync s75sudo s99rc. Local
S20speech-Dispatcher s50saned s99acpi- Support
Now that the K09apache2 file has appeared, and the previous s91apache2 file is not there, the configuration succeeds here.
Check the Apache service running status after reboot:
Here are some differences about MySQL's boot configuration:
After 10.04, the MySQL boot was connected to/lib/init/upstart-job, and the latter was called/etc/init/ mysql.conf file on the definition of the boot, this is the new framework, so the previous method no matter, we need to modify the mysql.conf file, first view the file:
HP@HP-Compaq-Presario-CQ45-Notebook-PC:/etc$ sudo vi/etc /init/mysql. conf
# MySQL Service
Description "MySQL Server"
Author "Mario Limonciello <superm1@ubuntu.com>"
Start on RunLevel [2345]
Stop on starting RC RUNLEVEL=[016]
Respawn
Respawn Limit 2 5
This shows the runlevel in bold red, we just need to change the line to start on RunLevel [345] (Note that sudo permission is required here), that is, delete RunLevel 2.
Check the MySQL service running status after reboot:
Reference links
http://space.itpub.net/370491/viewspace-216954
Http://wowubuntu.com/ubuntu1004-close-mysql.html
Http://zh.wikipedia.org/wiki/%E8%BF%90%E8%A1%8C%E7%BA%A7%E5%88%AB
Linux Boot startup settings