业务初始化-lamp脚本
!/bin/bash
lamp install script from Bai Shuming
date:2015-05-15
release 1.0
os rhel6
PACKAGES="../soft"
NOW=pwd
APR=apr-1.5.2.tar.bz2
APR_UTIL=apr-util-1.5.4.tar.bz2
APR_ICONV=apr-iconv-1.2.1.tar.bz2
APACHE=httpd-2.4.12.tar.bz2
D_PATH="/usr/local"
S_PATH="/usr/src"
MYSQL=mysql-5.5.29.tar.gz
LIBICONV=libiconv-1.14.tar.gz
LIBMCRYPT=libmcrypt-2.5.8.tar.gz
MCRYPT=mcrypt-2.6.8.tar.gz
MHASH=mhash-0.9.9.9.tar.gz
PHP=php-5.6.9.tar.bz2
check
check () {
必须是root用户才可以
[ $UID -ne 0 ]&&echo "need to root is that"&&exit 1
安装依赖
yum search elinks &>/dev/null
if [ ? -ne 0 ]&&echo "YUM: ERROR"&&exit 1
else
echo "YUM: ERROR";exit 1
fi
}
apr
apr () {
if [ -f APR ];then
tar xf APR -C
APR|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/apr 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ S_PATH/
APR , EIXT...";exit 1
fi
}
apr-util
apr_util () {
if [ -f APR_UTIL ];then
tar xf APR_UTIL -C
APR_UTIL|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/apr-util --with-apr=
? -eq 0 ];then
make 1>/dev/null
if [ ? -ne 0 ];then
echo "APR-util: Make install ERROR , EXIT...";exit 1
else
cd -;rm -rf CUR_PACKAGE
fi
else
echo "APR-util: make ERROR , EXIT...";exit 1
fi
else
echo "APR-util: Configure ERROR , EXIT...";exit 1
fi
else
echo "APR-util: Tar Command ERROR , EXIT...";exit 1
fi
else
echo "APR-util: Not fount $APR_UTIL , EIXT...";exit 1
fi
}
apr_iconv () {
if [ -f APR_ICONV ];then
tar xf APR_ICONV -C
APR_ICONV|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/apr-iconv --with-apr=
? -eq 0 ];then
make 1>/dev/null
if [ ? -ne 0 ];then
echo "APR-iconv: Make install ERROR , EXIT...";exit 1
else
cd -;rm -rf CUR_PACKAGE
fi
else
echo "APR-iconv: make ERROR , EXIT...";exit 1
fi
else
echo "APR-iconv: Configure ERROR , EXIT...";exit 1
fi
else
echo "APR-iconv: Tar Command ERROR , EXIT...";exit 1
fi
else
echo "APR-iconv: Not fount $APR_ICONV , EIXT...";exit 1
fi
}
apache () {
apr;apr_util;apr_iconv
[ $? -ne 0 ]&&"ERROR: Please check apr install" && exit 1
if [ -f APACHE ];then
tar xf APACHE -C
APACHE|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/apache --with-apr=
D_PATH/apr-util/ --enable-module=so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --with-mpm=prefork --enable-nonportable-atomics --disable-ipv6 --with-sendfile 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ S_PATH/
APACHE , EIXT...";exit 1
fi
}
mysql
mysql_install_post_set () {
useradd -s /sbin/nologin -r mysql
mkdir -pv /usr/local/mysql/data
cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chown mysql.mysql /usr/local/mysql/ -R
ln -s /usr/local/mysql/bin/* /usr/bin/
ln -s /usr/local/mysql/lib/* /usr/lib/
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/man8/* /usr/share/man/man8
sh scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 1>/dev/null
}
mysql () {
if [ -f MYSQL ];then
tar xf MYSQL -C
MYSQL|awk -F ".tar" '{print
S_PATH/
S_PATH/
? -eq 0 ];then
make 1>/dev/null
if [ ? -ne 0 ];then
echo "MYSQL: Make install ERROR , EXIT...";exit 1
else
mysql_install_post_set
cd - ;rm -rf CUR_PACKAGE
fi
else
echo "MYSQL: make ERROR , EXIT...";exit 1
fi
else
echo "MYSQL: Configure ERROR , EXIT...";exit 1
fi
else
echo "MYSQL: Tar Command ERROR , EXIT...";exit 1
fi
else
echo "MYSQL: Not fount $APACHE , EIXT...";exit 1
fi
}
php
libiconv () {
if [ -f LIBICONV ];then
tar xf LIBICONV -C
LIBICONV|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/apr 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ S_PATH/
LIBICONV , EIXT...";exit 1
fi
}
libmcrypt () {
if [ -f LIBMCRYPT ];then
tar xf LIBMCRYPT -C
LIBMCRYPT|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/libmcrypt 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ ? -eq 0 ];then
echo "export LD_LIBRARY_PATH=NOW;rm -rf
CUR_PACKAGE
else
echo "LIBMCRYPT(libltdl) ERROR,EXIT....";exit 1
fi
fi
else
echo "LIBMCRYPT: make ERROR , EXIT...";exit 1
fi
else
echo "LIBMCRYPT: Configure ERROR , EXIT...";exit 1
fi
else
echo "LIBMCRYPT: Tar Command ERROR , EXIT...";exit 1
fi
else
echo "LIBMCRYPT: Not fount $LIBMCRYPT , EIXT...";exit 1
fi
}
mhash () {
if [ -f MHASH ];then
tar xf MHASH -C
MHASH|awk -F ".tar" '{print
S_PATH/
S_PATH/
? -eq 0 ];then
make 1>/dev/null
if [ ? -ne 0 ];then
echo "MHASH: Make install ERROR , EXIT...";exit 1
else
ln -s /usr/local/lib/* /usr/lib/
ln -s /usr/local/bin/libmcrypt-config /usr/bin/
cd -;rm -rf CUR_PACKAGE
fi
else
echo "MHASH: make ERROR , EXIT...";exit 1
fi
else
echo "MHASH: Configure ERROR , EXIT...";exit 1
fi
else
echo "MHASH: Tar Command ERROR , EXIT...";exit 1
fi
else
echo "MHASH: Not fount $MHASH , EIXT...";exit 1
fi
}
mcrypt () {
if [ -f MCRYPT ];then
tar xf MCRYPT -C
MCRYPT|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/libmcrypt 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ S_PATH/
MCRYPT, EIXT...";exit 1
fi
}
php () {
libiconv;libmcrypt;mhash;mcrypt
[ $? -ne 0 ]&&echo "check php libiconv and encrypt install"&&exit 1
if [ -f PHP ];then
tar xf PHP -C
PHP|awk -F ".tar" '{print
S_PATH/
S_PATH/
D_PATH/php --with-config-file-path=
D_PATH/mysql/ --with-mysqli=
D_PATH/mysql --with-iconv-dir=/usr/local/ --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --disable-phar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt=
D_PATH/apache/bin/apxs 1>/dev/null
if [ ? -eq 0 ];then
make install 1>/dev/null
if [ D_PATH/apache/conf/httpd.conf
cp php.ini-production S_PATH/
PHP, EIXT...";exit 1
fi
}
case 0: apache|mysql|php|lamp";;
esac
网友评论