Sunday, November 14, 2010

Setting Up a Bare CentOS server with Ngnix/PHP/MySQL (part 2)

This post shows how to install a minimal CentOS server with no GUI and how to remove unneeded services.

Single CD Install
You only need CD or DVD #1 to do the basic install.
No graphics needed either.

NetInstall
You can also use the small netinstall CD, if you prefer. Sometimes it seems that it's faster to just start with the netinstall CD than to download all the updates.

Minimal Install Steps

  1. Boot to CD #1
  2. At the Boot: prompt, type in "linux text" to get the text installation setup
  3. Proceed normally with the installation until it asks which packages to install
  4. Deselect all of the packages and then click on the "customize package selection" check box
  5. Hold down the "-" (dash) key, which scrolls through all of the package options and deselects them all
  6. Finish the installation
  7. Do a "yum update" to get latest versions of everything
  8. Do a "yum install " for what ever other packages you need

After that we have an updated system.
Next we should also look at some services that start with the system.
Here is a list of services (daemons) to help you decide what to axe. Here is another list.

Run the following to see what is enabled:

chkconfig --list |grep "3:on" |awk '{print $1}' |sort

then save it to a file, a “before” file.

chkconfig --list |grep "3:on" |awk '{print $1}' |sort > before

After performing a minimal installation, the machine reboots. When you login disable as many services as possible with the following commands:

chkconfig anacron off
chkconfig apmd off
chkconfig atd off
chkconfig autofs off
chkconfig cpuspeed off
chkconfig cups off
chkconfig cups-config-daemon off
chkconfig gpm off
chkconfig isdn off
chkconfig netfs off
chkconfig nfslock off
chkconfig openibd off
chkconfig pcmcia off
chkconfig portmap off
chkconfig rawdevices off
chkconfig readahead_early off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig smartd off
chkconfig xfs off
chkconfig ip6tables off
chkconfig avahi-daemon off
chkconfig firstboot off
chkconfig yum-updatesd off
chkconfig sendmail off
chkconfig mcstrans off
chkconfig pcscd off
chkconfig bluetooth off
chkconfig hidd off
The next group of services is more useful to servers in some circumstances.
xinetd -- may be needed for some servers
acpid -- needed for power button to shut down server gently
microcode_ctl -- not needed on AMD machines
irqbalance -- not needed unless running SMP, multiple cores, multiple processors, hyperthreading
haldaemon and messagebus -- support for plug and play devices
mdmonitor -- not needed unless running software RAID

Evaluate their worth even more closely before disabling them.

chkconfig xinetd off
chkconfig acpid off
chkconfig microcode_ctl off
chkconfig irqbalance off
chkconfig haldaemon off
chkconfig messagebus off
chkconfig mdmonitor off

After you disabled the services you don’t need save the “after”file

chkconfig --list |grep "3:on" |awk '{print $1}' |sort > after 

then compare

diff before after

If you see anacron and kudzu, they only run at startup and will not stay loaded when finished.

Virtual Terminals

You may also minimize on virtual terminals. The default is six virtual terminals. You can probably do with two.

To disable them, edit the /etc/inittab file and comment out the ones that you don't want running like this:

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6

Sources:

Minimal Services on CentOS 5 Mini How To

Centos 5 Minimal Server Installation

No comments:

Post a Comment