Shell脚本自动部署(编译)LAMP平台
#!/bin/bash#Auth AnyISalIn
#Version 0.01
#On CentOS 6
#
cat > /etc/yum.repos.d/ustc.repoInstall httpd (deepend on apr and apr-util)
mariadb=====> Install MariaDB
php =====> Install php(The module provides, Need MariaDB and Httpd)
all =====> Install All : apr --> apr-util --> httpd --> MariaDB --> php
EOF
}
if $(yum repolist &> /dev/null); then
echo "Please With, Some may want to install Pkgs"
yum groupinstall -y "Development Tools" "Server Platform Development" &> /dev/null
echo "Installed Complete"
if [ $? -gt 0 ]; then
echo "Install pkgs group failure"
exit 1
fi
else
echo "Your repository is not available"
exit 1
fi
function apr {
cat/dev/null
if [ $? -eq 0 ]; then
make -j 4 &> /dev/null && make install &> /dev/null
else
echo "apr configure failure"
exit 2
fi
cat/dev/null && make install &> /dev/null
else
echo "apr-util configure failure"
exit 2
fi
cat/dev/null
if [ $? -eq 0 ]; then
make -j 4 &> /dev/null && make install &> /dev/null
else
echo "httpd configure failure"
exit 2
fi
cat > /etc/init.d/httpd &/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
EOF
chmod a+x /etc/init.d/httpd
chkconfig --add httpd
service httpd start &> /dev/null
if [ $? -gt 0 ]; then
echo "Install some problems "
exit 2
fi
cat/dev/null ]; then
echo "Group mysql is exists"
else
groupadd -g 3306 -r mysql
fi
if [[ ! $(id mysql &> /dev/null) ]]; then
useradd -r -u 3306 mysql -g mysql -s /sbin/nologin
else
echo "User mysql is exists"
fi
chown -R mysql.mysql.
mkdir /mydata ; chown -R mysql.mysql $!
./scripts/mysql_install_db --datadir=/mydata --user=mysql &> /dev/null
if [ $? -gt 0 ]; then
echo "initialize mysql_db is failure"
exit 1
fi
install support-files/mysql.server /etc/rc.d/init.d/mysqld || echo "Create start script file failure" exit 1
chkconfig --add mysqld || exit 1
install support-files/my-large.cnf /etc/my.cnf || $( echo "Create conf file failure" exit 1 )
sed -i '41adatadir = /mydata' /etc/my.cnf || $( echo "edit config failure" && exit 1 )
sed -i '42ainnodb_file_per_table = on ' /etc/my.cnf || $( echo "edit config failure" && exit 1 )
sed -i '43askip_name_resolve = on ' /etc/my.cnf || $( echo "edit config failure" && exit 1 )
service mysqld start &> /dev/null || $(echo "start mysqld failure" && exit 1)
service mysqld start &> /dev/null
cat/dev/null
if [ $? -eq 0 ]; then
make -j4 &> /dev/null && make install &> /dev/null
else
echo "configure is failure"
exit 1
fi
install php.ini-production /etc/php.ini
sed -i '378aAddType application/x-httpd-php .php' /etc/httpd24/httpd.conf
sed -i '379aAddtype application/x-httpd-php-source .phps' /etc/httpd24/httpd.conf
sed -i 's/DirectoryIndex.*index.*/DirectoryIndex index.php index.html/g' /etc/httpd24/httpd.conf
cat >> /usr/local/apache/htdocs/index.php
页:
[1]