You are here

CentOS


LAMP Server
  • Install the base OS (the minimal ISO will do nicely)
  • Configure networking and hostname (test that The Internet is accessible)
  • Install, configure & start Apache (new VirtualHost configurations will go in /etc/httpd/vhosts.d/*.conf)
    # yum install httpd ; \
    cp -v /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original ; \
    sed -ie 's|^Include conf.d\/\*.conf|Include conf.d\/\*.conf\nInclude vhosts.d\/\*.conf|' /etc/httpd/conf/httpd.conf ; \
    sed -ie 's/DirectoryIndex index.html index.html.var/DirectoryIndex index.php index.cgi index.html index.html.var/' /etc/httpd/conf/httpd.conf ; \
    sed -ie 's/^#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi/' /etc/httpd/conf/httpd.conf ; \
    sed -ie 's/^#NameVirtualHost *:80/NameVirtualHost *:80/' /etc/httpd/conf/httpd.conf ; \
    mkdir -p /etc/httpd/vhosts.d ; \
    apachectl -S && apachectl start && chkconfig httpd on
  • Install, start & secure MySQL
    # yum install mysql-server ; \
    service mysqld start && chkconfig mysqld on && mysql_secure_installation
  • Add the following line into /etc/my.cnf in the [mysql] section (and it will keep you in the know about which DB you're using)
    prompt="MySQL:\d> "
  • Tune MySQL (you'll probably want to tune again periodically)
    # mkdir -p bin && cd bin && wget mysqltuner.pl && chmod +x mysqltuner.pl && ./mysqltuner.pl
  • Install PHP (you may need to edit /etc/php.ini in the future)
    # yum install php php-pear php-mysql
  • Install the RPMForge/repoforge repo
    • Import the RPM GPG key for the new repo
      # rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
    • Install the new repo
      # yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
  • Install your desired packages
    # yum install zsh screen vim-enhanced figlet htop iftop xterm fluxbox xrdp someothershit
  • Make sure everything is up-to-date (and grab a local list of installed and available packages, which you can quickly search with grep/less)
    # yum clean all ; yum update && yum list >yl
  • Install OSSEC, a Host-based Intrusion Detection System
    # wget http://www.ossec.net/files/ossec-hids-latest.tar.gz && \
    tar zxvf ossec-hids-latest.tar.gz && \
    cd ossec-hids-* && \
    ./install.sh
  • Reboot (in order to test that you have everything configured as desired, your environment is clean & that a reboot actually succeeds)
    # reboot


SMTP MTA (Mail Server)


Postfix SMTP

Postfix is the MTa weapon of choice (for me)


Dovecot IMAP


SASL AUTH



Script to modify a grub configuration to launch a CentOS 6 netinstall in graphical mode, on reboot


#!/bin/bash
clear
echo
echo "Network Boot Install Script for CentOS"
echo "(c) alexsmith.im 2009-2010"
echo
echo "This script gives you the ability to install and use the VNC based network installer built into the"
echo "CentOS and Fedora Core network images."
echo
echo "It will walk you through your settings and reboot the server when required, please only run this script"
echo "if you are happy to lose the contents of this machines hard drive(s)"
echo
echo "This script comes without guarantee that it will work if it breaks your server I cannot be held responsible"
echo "I have tested it on my servers and it works without issue, if you do find a bug please report it"
echo "to me via my site at http://alexsmith.im - Thanks"
echo
echo " Please choose one of the following options"
echo
echo "A) Install CentOS 6.x 32 Bit"
echo "B) Install CentOS 6.x 64 Bit"
echo "X) Quit this installer"
echo
echo -n "Select an option and hit [ENTER]: "
read option

rm -rf /setup
mkdir /setup
cd /setup

case "$option" in

"a" | "A" )

echo
echo "Installing CentOS 6 32 Bit"
wget -4 -q http://mirror.ovh.net/ftp.centos.org/6/os/i386/images/pxeboot/initrd.img -O /setup/initrd.img
wget -4 -q http://mirror.ovh.net/ftp.centos.org/6/os/i386/images/pxeboot/vmlinuz -O /setup/vmlinuz
mirror="http://mirror.ovh.net/ftp.centos.org/6/os/i386/"
;;

"b" | "B" )

echo
echo "Installing CentOS 6 64 Bit"
wget -4 -q http://mirror.ovh.net/ftp.centos.org/6/os/x86_64/images/pxeboot/initrd.img -O /setup/initrd.img
wget -4 -q http://mirror.ovh.net/ftp.centos.org/6/os/x86_64/images/pxeboot/vmlinuz -O /setup/vmlinuz
mirror="http://mirror.ovh.net/ftp.centos.org/6/os/x86_64/"
;;

"x" | "X" )

echo "Quitting"
exit
;;

esac

echo
echo "Detecting required system settings..."
gateway=`netstat -nr | grep UG | awk '{print $2}'`
echo "Gateway detected as $gateway"
ip=`ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut -d : -f 2`
echo "IP detected as $ip"

echo
echo
echo "This password is purely for VNC access and it doesn't like long ones"
echo -n "So please enter a SHORT (6 chars or less) password for VNC and hit [ENTER]: "
read password

cp /setup/initrd.img /boot/pxe.initrd.img
cp /setup/vmlinuz /boot/pxe.vmlinuz

echo
echo "Forcing install of Grub..."
yum install grub -y > /dev/null

echo "Creating boot menu..."
if [ -s /boot/grub/menu.lst ]
then
rm /boot/grub/menu.lst
fi

# Make menu.lst with correct settings
cat > /boot/grub/menu.lst default 0
timeout 5
title PXE Install Boot
root (hd0,0)
kernel /boot/pxe.vmlinuz vnc vncpassword=$password headless ip=$ip netmask=255.255.255.0 gateway=$gateway dns=8.8.8.8 ksdevice=eth0 method=$mirror lang=en_US keymap=us
initrd /boot/pxe.initrd.img
DELIM

if [ -s /boot/grub/grub.conf ]
then
rm /boot/grub/grub.conf
cp /boot/grub/menu.lst /boot/grub/grub.conf
fi

echo "Installing Grub to the first disk..."
grub-install /dev/sda > /dev/null
echo "Checking Grub Install..."
grub-install --recheck /dev/sda > /dev/null

echo
echo "PRE-SETUP COMPLETE"
echo
echo "Once the server is rebooted VNC will start up and you will be able to carry on the install as normal"
echo "This includes doing your partitioning and installing your packages"
echo
echo "You will be able to connect to the VNC Server using $ip:1 as the host"
echo
echo "The reboot can take a few minutes, depending on the speed of your server and if the mirror is busy"
echo "If you would like to reboot the server now to start the installation of your server please hit [ENTER] now, otherwise press ctrl+c"
read -s
echo "Rebooting!"
reboot