#/bin/bash # LY # ------------------ # copyright 2016.04.16 LingYi ([email protected]) QQ:1519952564 # "install wordpress service" DataBaseUser='root' DataBasePwd='' #the password will be DataBaseDefPwd='rootroot' DataBaseName='wordpress' WebrootPath='/var/www/html' echo -e "\033[1;32mInstall software ....\033[0m" yum install -y httpd MysqL-server PHP PHP-MysqL yum install -y PHP-gd PHP-imap PHP-ldap PHP-odbc PHP-pear PHP-xml PHP-xmlrpc yum install -y wget unzip expect echo -ne "\033[1;32mSet httpd and MysqL run on start-up ... \033[0m" if chkconfig httpd on && chkconfig MysqLd on &>/dev/null; then echo -e "\033[1;32m [ OK ]\033[0m" else echo -e "\033[1;31m [ FAIL ]\033[0m" exit 10 fi echo -e "\033[1;32mGet wordpress ... \033[0m" if ! wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip; then echo -e "\033[1;31m Can not get wordpress !!!\033[0m" exit 11 fi echo -e "\033[1;32mUnzip wordpress ... \033[0m" if ! unzip wordpress-3.9-zh_CN.zip &>/dev/null; then echo -e "\033[1;31m Can not unzip wordpress !!!\033[0m" exit 12 fi echo -e "\033[1;32mModify wordpress configuration file ... \033[0m" sed -i "s/database_name_here/$DataBaseName/" wordpress/wp-config-sample.PHP sed -i "s/username_here/$DataBaseUser/" wordpress/wp-config-sample.PHP sed -i "s/password_here/${DataBasePwd:-$DataBaseDefPwd}/" wordpress/wp-config-sample.PHP mv wordpress/wp-config-sample.PHP wordpress/wp-config.php echo -e "\033[1;32mcoping wordpress files to web root directory ... \033[0m" if cp -a wordpress/* $WebrootPath; then rm -fr wordpress* else echo -e "\033[1;31m copy files Failed !!!\033[0m" fi if ! service httpd status &>/dev/null; then usermod -d $WebrootPath apache &>/dev/null else service httpd stop &>/dev/null && usermod -d $WebrootPath apache fi echo -e "\033[1;32mModify permissions of wordpress files ... \033[0m" if ! chown apache:apache -R $WebrootPath; then echo echo -e "\033[1;31m [ FAIL ]\033[0m" exit 12 fi echo -ne "\033[1;32mStarting http and MysqL ... \033[0m" if service httpd start &>/dev/null && service MysqLd start &>/dev/null; then echo -e "\033[1;32m [ OK ]\033[0m" else echo -e "\033[1;31m [ FAIL ]\033[0m" exit 13 fi echo -ne "\033[1;32mOperating MysqL ... \033[0m" if [[ -z $DataBasePwd ]]; then DataBasePwd=$DataBaseDefPwd MysqLadmin -u $DataBaseUser flush-privileges password "$DataBasePwd" &>/dev/null fi expect -c " spawn MysqL -u $DataBaseUser -p"$DataBasePwd" expect { \"MysqL>\" { send \"create database wordpress;\r\" send \"quit;\r\" interact } } " &>/dev/null if [[ $? -eq 0 ]]; then echo -e "\033[1;32m [ OK ]\033[0m" else echo -e "\033[1;31m [ FAIL ]\033[0m" fi
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。