标签:一键安装lamp环境
#一键安装lamp环境}
function mysqlset(){
echo "PATH=/usr/local/mysql/bin:$PATH">>/etc/profile
source /etc/profile
chown -R mysql:mysql /usr/local/mysql/
check_ok
cd /usr/local/mysql/scripts/
./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
chenk_ok
[ -f "/etc/my.cnf" ] && rm -f /etc/my.cnf
cp -f /usr/local/src/mysql-5.6.35/support-files/my-default.cnf /etc/my.cnf
sed -i ‘/^[mysqld]$/a\user = mysql \nbasedir = /usr/local/mysql\ndatadir = /usr/local/mysql/data\nsocket = /tmp/mysql.sock‘ /etc/my.cnf
cp -f /usr/local/src/mysql-5.6.35/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i ‘s#^datadir=#datadir=/usr/local/mysql/data#‘ /etc/init.d/mysqld
sed -i ‘s#^basedir=#basedir=/usr/local/mysql#‘ /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
check_ok
}
function install_apache(){
echo "apache2.4.25 will be installed,please wait minitunes"
yum -y install expat-devel
check_ok
path="/usr/local/src/"
cd $path
apachetar="httpd-2.4.29.tar.gz"
aprtar="apr-1.6.3.tar.gz"
aprutiltar="apr-util-1.6.1.tar.gz"
pcretar="pcre-8.41.tar.gz"
[ ! -f "$apachetar" ] && wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz || continue
check_ok
[ ! -f "$aprtar" ] && wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz || continue
check_ok
[ ! -f "$aprutiltar" ] && wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz || continue
check_ok
[ ! -f "$pcretar" ] && wget --no-check-certificate https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz || continue
check_ok
tar -zxvf httpd-2.4.29.tar.gz
tar -zxvf apr-1.6.3.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
tar -zxvf pcre-8.41.tar.gz
check_ok
cd $path/apr-1.6.3
./configure --prefix=/usr/local/apr
make && make install
check_ok
cd $path/apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
chenk_ok
make && make install
check_ok
cd $path/pcre-8.41
./configure --prefix=/usr/local/pcre
check_ok
make && make install
check_ok
cd $path/httpd-2.4.29
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-mods-shared=most --enable-rewrite
check_ok
make && make install
check_ok
}
function apacheset(){
cp /usr/local/apache2.4/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
sed -i ‘2 i #chkconfig: 2345 10 90‘ /etc/init.d/httpd
sed -i ‘3 i #description: Activates/Deactivates Apache Web Server‘ /etc/init.d/httpd
check_ok
chkconfig httpd on
}
function install_php(){
echo "php will be installed,please be wait"
sleep 10
yum -y install zlib-devel libpng-devel curl libmcrypt-devel freetype-devel libxml2-devel openssl-devel bzip2-devel libjpeg-devel curl-devel gd
check_ok
cd /usr/local/src
phptar="php-5.6.30.tar.gz"
[ ! -f "$phptar" ] && wget http://cn2.php.net/distributions/php-5.6.30.tar.gz || continue
tar -zxvf php-5.6.30.tar.gz
mkdir -p /usr/local/php5
cd /usr/local/src/php-5.6.30
./configure --prefix=/usr/local/php5/ --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql/ --with-pdo-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-icon-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
check_ok
make && make install
}
function main(){
yum_update
yum_depend
install_mysql
mysqlset
install_apache
install_php
apacheset
}
main
标签:一键安装lamp环境
原文地址:http://blog.51cto.com/2179600/2095257