分类: LINUX
2008-12-06 15:41:07
#/bin/bash
#System Configuration Steps:
#Created by ritto.zhao
#MSN:
#20081011
#sed -i 's#GATEWAY=192.168.4.1#GATEWAY=192.168.4.3\n#' /etc/sysconfig/network
#/etc/init.d/network restart
#yum source
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.save
wget
#package install
#new package install_ritto_20081119
yum -y install gcc gcc-c++ flex bison autoconf automake libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel openssl openssl-devel gettext gettext-devel curl curl-devel apr-util apr-util-devel gdbm gdbm-devel pcre pcre-devel pam pam-devel libiconv libiconv-devel libmcrypt libmcrypt-devel
###############################################################
#Install MySQL
yum -y remove mysql
userdel -r mysql
#wget
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.29-rc.tar.gz/from/http://mirror.x10.com/mirror/mysql/
mkdir /data
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql -s /sbin/nologin -d /data/mysql mysql
chmod -R 755 /data/mysql
chown -R mysql:mysql /data/mysql
tar zxvf mysql-5.1.29-rc.tar.gz
cd mysql-5.1.29-rc/
./configure \
"--prefix=/usr/local/mysql/" \
"--enable-assembler" \
"--with-extra-charsets=complex" \
"--enable-thread-safe-client" \
"--with-big-tables" \
"--with-readline" \
"--with-ssl" \
"--with-embedded-server" \
"--with-big-tables" \
"--enable-local-infile" \
"--with-innodb"
make
make install
chown -R mysql:mysql /usr/local/mysql
mkdir /data/mysqllog
chown -R mysql:mysql /data/mysqllog
#cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
cd /usr/local/mysql
wget
/usr/local/mysql/bin/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf
#boot mysql
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &
echo "/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &" >> /etc/rc.d/rc.local
#Security setting
/usr/local/mysql/bin/mysql -uroot -e "set password for privileges;"
cd ../
modify files:
/usr/local/mysql/my.cnf
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/ritto.pid
log-error = /data/mysqllog/ritto-err.log
log-bin = /data/mysqllog/ritto-bin.bin
binlog_format=mixed
log-output = FILE
skip-locking
#################################################################
#Install Apache
yum -y remove httpd
rum -y remove php-common
wget
tar xvf gd-2.0.36RC1.tar
cd gd-2.0.36RC1
./configure
make
make install
cd ..
wget
tar -zxvf httpd-2.2.10.tar.gz
cd httpd-2.2.10
./configure --prefix=/usr/local/apache2 \
--enable-so \
--enable-mods-shared=all \
--enable-cgi \
--enable-info \
--enable-rewrite \
--enable-speling \
--enable-usertrack \
--enable-deflate \
--enable-ssl \
--enable-mime-magic \
--enable-cache \
--enable-file-cache \
--enable-mem-cache \
--enable-disk-cache \
--enable-static-ab
make
make install
/usr/local/apache2/bin/apachectl start
#Set apache boot autorun:
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local
cd ../
##########################################################
#Install PHP
wget
#wget
tar zxvf php-5.2.6.tar.gz
cd php-5.2.6
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-config-file-path=/usr/local/php/etc \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-bz2 \
--with-freetype-dir \
--with-iconv-dir=/usr/local \
--with-openssl \
--with-mcrypt \
--with-curl \
--with-curlwrappers \
--with-openssl \
--with-libxml-dir=/usr \
--with-ttf \
--with-gd \
--with-gdbm \
--enable-gd-native-ttf \
--enable-shared \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-xml \
--enable-calendar \
--enable-wddx \
--enable-dba \
--enable-safe-mode
make && make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
sed -i 's#AddType application/x-gzip .gz .tgz#AddType application/x-gzip .gz .tgz\n AddType application/x-httpd-php .php .php3\n AddType application/x-httpd-php-source .phps#' /usr/local/apache2/conf/httpd.conf
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
------------------------------------------------------------------------
//如出现iconv错误
/usr/local/php/bin/php -v
5.2.6
sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#' Makefile
------------------------------------------------------------------------
##########################################################
#Install eaccelerator
#eaccelerator是PHP的加速软件,使用后PHP的执行效率会有较大幅度的提升
wget
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
mkdir /usr/local/eaccelerator_cache
chmod 0777 /usr/local/eaccelerator_cache
vi /usr/local/php/etc/php.ini
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
vi /etc/sysctl.conf
kernel.shmmax = 134217728
/sbin/sysctl -p
##########################################################
#Install PDO_MySQL
wget
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
cd ../
##########################################################
#Install memcache
#memcached是一个高性能的分布式内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表
#它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等
#起初作者编写它可能是为了提高动态网页应用,为了减轻数据库检索的压力,来做的这个缓存系统。
#它的缓存是一种分布式的,也就是可以允许不同主机上的多个用户同时访问这个缓存系统,
#这种方法不仅解决了共享内存只能是单机的弊端,同时也解决了数据库检索的压力,最大的优点
wget
tar zxvf memcache-2.2.4.tgz
cd memcache-2.2.4/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
vi /usr/local/php/etc/php.ini
手动修改:
查找/usr/local/php/etc/php.ini中的extension_dir = "./"
修改为extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
再查找output_buffering = Off
修改为output_buffering = On
自动修改:
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
##########################################################
#Install squid
wget
tar jxvf squid-2.6.STABLE16.tar.bz2
cd squid-2.6.STABLE16
./configure --prefix=/usr/local/squid --enable-async-io=500 --with-maxfd=65536 --disable-delay-pools --disable-mem-gen-trace --disable-useragent-log --enable-kill-parent-hack --disable-arp-acl --enable-epoll --disable-ident-lookups --enable-snmp --enable-large-cache-files --with-large-files --with-pthreads --enable-underscore --enable-storeio="aufs,coss,diskd,ufs"
make && make install
未完待遇.......
#优化Linux内核参数
vi /etc/sysctl.conf
在末尾增加以下内容:
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
/sbin/sysctl -p