一、系统安装

   一、  系统安装

  1. 准备工作:操作系统版本,规划分区信息,IP地址,掩码,网关,root口令
  2. 操作系统版本选择Centos4.7
  3. 分区    对于整个硬盘选择自动分区
  4. 配置静态IP,Gateway,DNS Server,Hostname(根据情况可不设定dns)
  5. 防火墙 选中 Remote Login(SSH)   选中 Web Server(HTTP,HTTPS)
  6. 安装方试可以通过光盘,pxe安装等   
  7. 语言:选择English(USA)
  8. 时区:Aisa/Shangai
  9. 软件包:选中
        X Window System
        GNOME Desktop Environmen
        Editors
        Development Tools
        X software Development
        Legacy Software Development

  二、  安装后的必要配置

  1. 修改默认运行级别为:3
  2.  sed  -i -e  "s/id:5:initdefault:/id:3:initdefault:/" /etc/inittab
  3. 配置时间同步:
  4.  /usr/sbin/ntpdate 210.72.145.44
  5. 修改启grup.conf的启动timeout=0
  6.   sed -i -e  "s/timeout=5/timeout=1/" /boot/grub/grub.conf
  7. 关闭IPV6
  8. echo "alias net-pf-10 off" >> /etc/modprobe.conf
    echo "alias ipv6 off" >> /etc/modprobe.conf
    /sbin/chkconfig --level 35 ip6tables off
  9. 关闭不必要的服务
  10.   for ser in `chkconfig --list   |grep 3:on |awk '{print $1}'`
                do
                    echo $ser
                    case $ser in
                      crond | irqbalance | microcode_ctl | network | random | sendmail \
                            | sshd | syslog | messagebus | haldaemon | readahead_early \
                            | apmd | readahead_later | readahead | iptables | lvm2-monitor | xinetd | auditd | cpuspeed )
                    echo "Base services, Skip"
                 ;;
                 *)
                     echo "change $ser to off"
                     chkconfig --level 3 $ser off
                     service $ser stop
    
                 ;;
    
                    esac
            done
    }
相关资源
         1.适用于centos4 系列一个KS文件
         2. 系统配置脚本
         3.防火墙脚本

二、  编译安装基本环境

  1、 编译安装MySQL

              tar zxvf mysql-5.1.30.tar.gz
              cd mysql-5.1.30
              groupadd mysql
              useradd -g mysql mysql -s /sbin/nologin
              ./configure --prefix=/usr/local/mysql \
                          --localstatedir=/usr/local/mysql/var \
                          --with-client-ldflags=-all-static \
                          --with-mysqld-ldflags=-all-static \
                          --enable-assembler  \
                          --without-innodb \
                          --without-isam \
                          --with-pthread \
                          --enable-thread-safe-client \
                          --with-extra-charsets=all
              make&&make install
              \cp –f support-files/my-medium.cnf /etc/my.cnf
              \cp –f support-files/mysql.server /etc/rc.d/init.d/mysqld
              chmod 700 /etc/rc.d/init.d/mysqld
              chkconfig --add mysqld
              cd /usr/local/mysql
              sed -i 's/skip-federated/#skip-federated/' /etc/my.cnf
              bin/mysql_install_db --user=mysql    
              chown -R root  .
              chown -R mysql var
              chgrp -R mysql .
              bin/mysqld_safe --user=mysql &
 注意: 1.可通过如下脚本测试mysql是否安装或启动成功
               export PATH=$PATH:/usr/local/mysql/bin/
             mysql -e 'SELECT VERSION();'
        如果返回如下显示,则安装成功否则请查看mysql的日志.
              +-----------+
              | VERSION() |
              +-----------+
              | 5.1.30      |
              +-----------+
           本例中mysql的日志文件为/usr/local/mysql/var/`hostname`.err

     2、 编译安装Apache

              tar jxvf httpd-2.2.10.tar.bz2
              cd httpd-2.2.10
             ./configure  --prefix=/usr/local/apache2  \
                          --enable-static-support  \
                          --enable-static-htpasswd  \
                          --enable-static-htdigest  \
                          --enable-static-rotatelogs  \
                          --enable-static-logresolve  \
                          --enable-static-ab  \
                          --enable-static-checkgid  \
                          --enable-so  \
                          --enable-authz-host  \
                          --enable-mime  \
                          --enable-dir  \
                          --enable-log-config  \
                          --enable-auth-basic=shared  \
                          --enable-authn-file=shared  \
                          --disable-authn-default  \
                          --disable-authz-groupfile  \
                          --disable-authz-user  \
                          --disable-authz-default  \
                          --disable-include  \
                          --disable-filter  \
                          --disable-charset-lite  \
                          --disable-env  \
                          --disable-setenvif  \
                          --enable-autoindex  \
                          --disable-asis  \
                          --disable-cgid  \
                          --enable-cgi  \
                          --enable-negotiation=shared  \
                          --enable-actions=shared  \
                          --enable-alias  \
                          --enable-dav=shared \
                          --enable-dav-fs=shared
              make&&make install
 

  3、 编译安装PHP

              tar jxvf php-5.2.6.tar.bz2 
              cd php-5.2.6
              ./configure --prefix=/usr/local/php \
                             --with-apxs2=/usr/local/apache2/bin/apxs \
                             --with-pear --with-zlib-dir \
                             --with-libxml-dir --with-gd \
                             --enable-gd-native-ttf \
                             --enable-gd-jis-conv \
                             --with-freetype-dir --with-jpeg-dir \
                             --with-png-dir --with-ttf=shared \
                             --enable-mbstring \
                             --with-mysql=/usr/local/mysql \
                             --with-mysqli=/usr/local/mysql/bin/mysql_config \
                             --with-config-file-path=/etc --with-iconv \
                             --disable-ipv6 --enable-static \
                             --enable-zend-multibyte \
                             --enable-inline-optimization \
                             --enable-zend-multibyte \
                             --enable-sockets \
                             --enable-soap --with-openssl \
                             --with-gettext
              make&&make install

  4、 编译安装rrdtool(此软件不需要装,我在这里写出是因为我本人需要用这个做一些监控)

               tar zxvf rrdtool-1.2.29.tar.gz
               cd rrdtool-1.2.29
               yum install -y libart_lgpl-devel.i386
               ./configure  --prefix=/usr \
                            --disable-tcl  --disable-ruby
               make&&make install

三、  整合Apache与PHP                  

 vi /usr/local/apache2/config/httpd.conf
        1.添加用于解析以.php结尾的文件的指令   
                AddType application/x-httpd-php .php .phtml
                AddType application/x-httpd-php-source .phps  
        2.修改默认打开的页面为index.php 找到
                <IfModule dir_module>
                      DirectoryIndex index.html
                </IfModule>
       修改成:
                   <IfModule dir_module>
                     DirectoryIndex  index.php index.html
                </IfModule>

可用下面的脚本来进行

file=/usr/local/apache2/conf/httpd.conf
sed -i '309 a\ AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps' $file
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' $file

  找到:      

            #Include conf/extra/httpd-mpm.conf
            #Include conf/extra/httpd-info.conf
            #Include conf/extra/httpd-default.conf

     分别去掉前面的#保存退出

     测试整合        

            echo   '<?php phpinfo(); ?>' >/usr/local/apache2/htdocs/index.php
            /usr/local/apache2/bin/apachectl restart

四、  系统初化配置

             1、vi conf/extra/httpd-default.conf  修改以下列出的几项为如下                

            ServerTokens Prod
            ServerSignature Off
            HostnameLookups Off

           2、vi conf/extra/httpd-info.conf

            <Location /server-status>
                      SetHandler server-status
                      Order deny,allow
                      Deny from all
                      Allow from 10.11 127.0.0.1
            </Location>
            ExtendedStatus On