#!/bin/bash
#name:LAMPX.sh
#version:1.1
#author:Driver_C
#blog:http://www.zhuzhenlong.top
#time:2018-05-01
export HTT=`rpm -qa *httpd*`
export MAR_USER=`getent passwd mysql`
export HTT_USER=`getent passwd apache`
#配置yum源
fun_yum(){
cat << EOF > /etc/yum.repos.d/lampx.repo
baseurl=http://172.16.0.1/centos/7/
gpgcheck=0
[epel]
name=epel
baseurl=http://172.16.0.1/fedora-epel/7/x86_64/
gpgcheck=0
EOF
yum clean all
}
fun_prepare(){
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -ri.bak 's/(^SELINUX=).*/\1permissive/' /etc/selinux/config
source /etc/profile.d/app.sh
if [ -n "$MAR" ];then
yum -y remove *mariadb*
fi
fi
yum -y groupinstall "development tools"
if [ -e /root/src ];then
cd /root/src
if [[ ! -e /root/src/apr-1.5.2.tar.bz2 ]];then
wget ftp://twenty-four:Magedu24.com@172.17.0.1/Files/软件包/apr-1.5.2.tar.bz2
tar xvf apr-1.5.2.tar.bz2
else
tar xvf apr-1.5.2.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
else
tar xvf apr-util-1.5.4.tar.bz2
fi
if [[ ! -e /root/src/httpd-2.4.27.tar.bz2 ]];then
wget ftp://twenty-four:Magedu24.com@172.17.0.1/Files/软件包/httpd-2.4.27.tar.bz2
tar xvf httpd-2.4.27.tar.bz2
else
tar xvf httpd-2.4.27.tar.bz2
fi
if [[ ! -e /root/src/mariadb-10.2.7-linux-x86_64.tar.gz ]];then
tar xvf mariadb-10.2.7-linux-x86_64.tar.gz
else
tar xvf mariadb-10.2.7-linux-x86_64.tar.gz
fi
if [[ ! -e /root/src/php-7.1.7.tar.bz2 ]];then
wget ftp://twenty-four:Magedu24.com@172.17.0.1/Files/软件包/php-7.1.7.tar.bz2
tar xvf php-7.1.7.tar.bz2
else
tar xvf php-7.1.7.tar.bz2
tar xvf wordpress-4.8-zh_CN.tar.gz
else
tar xvf wordpress-4.8-zh_CN.tar.gz
fi
if [[ ! -e /root/src/xcache-3.2.0.tar.gz ]];then
wget ftp://twenty-four:Magedu24.com@172.17.0.1/Files/软件包/xcache-3.2.0.tar.gz
tar xvf xcache-3.2.0.tar.gz
else
tar xvf xcache-3.2.0.tar.gz
fi
else
mkdir /root/src
cd /root/src
wget ftp://twenty-four:Magedu24.com@172.17.0.1/Files/软件包/*
ls | xargs -n1 tar xvf
fi
}
fun_httpd(){
cd /root/src
mv apr-1.5.2 httpd-2.4.27/srclib/apr
mv apr-util-1.5.4 httpd-2.4.27/srclib/apr-util
cd httpd-2.4.27/
make && make install
#mariadb二进制包安装
fi
mv mariadb-10.2.7-linux-x86_64 /usr/local/mysql
chgrp -R mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
[[ ! -e /etc/mysql ]] && mkdir /etc/mysql
cp support-files/my-huge.cnf /etc/mysql/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
mysql -e "create database blog;grant all on *.* to 'blog'@'localhost' identified by 'blog';"
}
#php编译安装
fun_php(){
cd /root/src/php-7.1.7/
make && make install
cp php.ini-production /etc/php.ini
}
#xcache编译安装
fun_xcache(){
cd /root/src/xcache-3.2.0/
phpize
./configure --enable-xcache --with-phpconfig=/usr/bin/php-config
make && make install
cp -n xcache.ini /etc/php.d/
}
#wordpress安装
fun_wordpress(){
cd /root/src
cp -a wordpress/* /app/httpd24/htdocs/
chown -R apache /app/httpd24/htdocs
cp /app/httpd24/htdocs/wp-config-sample.php /app/httpd24/htdocs/wp-config.php
sed -ri 's/database_name_here/blog/' /app/httpd24/htdocs/wp-config.php
sed -ri 's/username_here/blog/' /app/httpd24/htdocs/wp-config.php
sed -ri 's/password_here/blog/' /app/httpd24/htdocs/wp-config.php
rm -f /app/httpd24/htdocs/index.html
}
#main
fun_yum
fun_prepare
fun_httpd
fun_mariadb
fun_php
fun_xcache
fun_wordpress
apachectl restart
service mysqld restart
echo "安装完成"
echo "数据库账号密码均为:blog"
echo "请登陆网站检查结果"
#unset
unset MAR HTT MAR_USER HTT_USER
exit