- #!/bin/bash
定义变量localpath为当前脚本的路径,作用是在后面使用变量来寻找程序包;
- localpath=`pwd`
判断是否存在文件/tmp/lamp_lock,如果有这个文件表明这个脚本已经运行了,作用是防止重复运行脚本.如果没有这个文件,这创建该文件,并继续后面的步骤;
- if [ -e /tmp/lamp_lock ]
- then
- echo "This script is running..."
- exit 9
- fi
- touch /tmp/lamp_lock
检查当前的操作系统和用户是不是满足安装的需求;
- system=`uname`
- if [ ! ${system}=Linux ]
- then
- echo "You system is not rhel 5.5!!"
- exit 11
- fi
- user=`echo $UID`
- if [ ! $user=0 ]
- then
- echo "You are not root!"
- exit 10
- fi
自定义函数,函数的作用是判断返回值是否为0;
拥有帝国一切,皆有可能。欢迎访问phome.net
- jubgement() {
- if [ ! $?=0 ]
- then
- echo "Is error!!!"
- exit
- fi
- }
用函数定义安装软件的版本,方便更改;
- phpver="5.2.14"
- httpdver="2.2.11"
- mysqlver="5.5.3-m3"
- mhashver="0.9.9.9"
- convver="1.13.1"
- libmcver="2.5.8"
- mcryptver="2.6.8"
- pdover="1.0.2"
- eAccver="0.9.6.1"
解压缩;
- tar fxz php-${phpver}.tar.gz 2>>/tmp/error.log
- tar fxj httpd-${httpdver}.tar.bz2 2>>/tmp/error.log
- tar fxz mysql-${mysqlver}.tar.gz 2>>/tmp/error.log
- tar fxz libiconv-${convver}.tar.gz 2>>/tmp/error.log
- tar fxz libmcrypt-${libmcver}.tar.gz 2>>/tmp/error.log
- tar fxz mcrypt-${mcryptver}.tar.gz 2>>/tmp/error.log
拥有帝国一切,皆有可能。欢迎访问phome.net
- tar fxz mhash-${mhashver}.tar.gz 2>>/tmp/error.log
- tar fxz PDO_MYSQL-${pdover}.tgz 2>>/tmp/error.log
- tar fxj eaccelerator-${eAccver}.tar.bz2 2>>/tmp/error.log
安装配置apache,并做了一个apache的启动脚本;
- cd ${localpath}/httpd-${httpdver}
- ./configure
- jubgement
- make && make install 2>>/tmp/error.log
- jubgement
- cat > /etc/rc.d/init.d/apache << EOF
- #!/bin/bash
- case $1 in
- start )
- /usr/local/apache2/bin/apachectl $1
- echo "apache [start]"
- ;;
- stop )
- /usr/local/apache2/bin/apachectl $1
- echo "apache [stop]"
- ;;
- restart )
- /usr/local/apache2/bin/apachectl $1
- echo "apache [stop]"
拥有帝国一切,皆有可能。欢迎访问phome.net
- sleep 2
- echo "apache [start]"
- esac
- EOF
- chmod a x /etc/rc.d/init.d/apache
- service apache start 2>>/tmp/error.log
- sleep 5
安装配置MySQL;
- CFLAGS="-06 -mpentumpro -fomit-frame-pointer"
- CXXFLAGS="-06 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
- yum install gcc gcc-c ncurses-devel libtool -y >& /dev/null
- cd ${localpath}/mysql-${mysqlver}
- useradd mysql
- ./configure
- jubgement
- make && make install 2>>/tmp/error.log
- jubgement
- cat ${localpath}/mysql-${mysqlver}/support-files/my-huge.cnf > /etc/my.cnf
- cat /usr/local/mysql/share/mysql/mysql.server > /etc/init.d/mysql
- chmod a x /etc/init.d/mysql
- /usr/local
拥有帝国一切,皆有可能。欢迎访问phome.net/mysql/bin/mysql_install_db
- chown mysql:mysql /usr/local/mysql -R
- mkdir /usr/local/mysql/data
- sed -i.bak ''/[mysqld]/a datadir=/usr/local/mysql/data'' /etc/my.cnf
- cat /etc/my.cnf|grep skip-name-resolve || sed -i ''/[mysqld]/a skip-name-resolve'' /etc/my.cnf
- echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf
- ldconfig
- ln -s /usr/local/mysql/bin/* /usr/local/bin/
- ln -s /usr/local/mysql/libexec/* /usr/local/libexec/
- ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1/
- ln -s /usr/local/mysql/share/man/man5/* /usr/share/man/man5/
- service mysql start 2>>/tmp/error.log
- sleep 5
安
|