[bash]http serevr部署wordpress
阿新 • • 發佈:2017-10-05
pri tps clas pac sys leg cto move psi
1 #!/bin/bash 2 # 3 echo "close selinux…" 4 sed -i ‘s/Enforcing/disabled/‘ /etc/sysconfig/selinux 5 source /etc/sysconfig/selinux 6 reboot 7 echo "empty iptables…" 8 iptables -F 9 echo "create workdir" 10 mkdir /root/wpconfigdir 11 echo "switch to workdir" 12 cd /root/wpconfigdir 13 echo "start to download wordpress packages…" 14 wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.zip 15 wpsize=`ls -l /root/wpconfigdir/ | grep wordpress | awk -F‘ ‘ ‘{print $5}‘` 16 echo "whether wordpress download successfully…" 17 if [ -f /root/wpconfigdir/wordpress-4.7.4-zh_CN.zip ] && [ "$wpsize" = "9245300" ];then 18 echo "download successfully…"; 19 else 20 echo "No such files…download failed…"; 21 fi 22 echo "installing httpd server…" 23 yum install -y httpd 24 echo "start httpd service…" 25 service httpd start 26 echo "installing mysql server application…" 27 yum install -y mysql mysql-server mysql-devel 28 echo "start mysqld service…" 29service mysqld start 30 echo "set password for root…" 31 /usr/bin/mysqladmin -u root password ‘admin123‘ 32 echo "restart mysqld service…" 33 service mysqld restart 34 echo "create wordpress database…" 35 mysql -uroot -padmin123 -e"create database wordpress;" 36 if [ $? -eq 0 ];then 37 echo "wordpress create successfully" 38 else 39 echo "create failed" 40 fi 41 echo "grant privileges to wpuser…" 42 mysql -uroot -padmin123 -e"grant all privileges on wordpress.* to ‘wpuser‘@‘localhost‘ identified by ‘admin123‘;" 43 mysql -uroot -padmin123 -e"grant all privileges on wordpress.* to ‘wpuser‘@‘127.0.0.1‘ identified by ‘admin123‘;" 44 mysql -uroot -padmin123 -e"grant all privileges on wordpress.* to ‘wpuser‘@‘192.168.%‘ identified by ‘admin123‘;" 45 mysql -uroot -padmin123 -e"flush privileges;" 46 echo "uncompress wordpress packages…" 47 unzip wordpress-4.7.4-zh_CN.zip 48 echo "move wordpress to / directory…" 49 mv wordpress/* /var/www/html/ 50 echo "installing php packages…" 51 yum install -y php php-devel php-mysql php-mbstring 52 echo "backup httpd config file…" 53 cp /etc/httpd/conf/httpd.conf{,.bak} 54 echo "add php index files…" 55 sed -i ‘s/DirectoryIndex.*/& index.php/‘ /etc/httpd/conf/httpd.conf 56 echo "backup wordpress config files…" 57 cp /var/www/html/wp-config-sample.php{,.bak} 58 mv /var/www/html/wp-config-sample.php /var/www/html/wp-config.php 59 echo "start configure wordpress infomations to connect mysqlserevr loacl…" 60 sed -i ‘s/database_name_here/wordpress/‘ /var/www/html/wp-config.php 61 sed -i ‘s/username_here/wpuser/‘ /var/www/html/wp-config.php 62 sed -i ‘s/password_here/admin123/‘ /var/www/html/wp-config.php 63 sed -i ‘/put your unique phrase here/d‘ /var/www/html/wp-config.php 64 mkdir wpconfigdir;touch /root/wpconfigdir/salt; 65 curl https://api.wordpress.org/secret-key/1.1/salt > /root/wpconfigdir/salt 66 cat /root/wpconfigdir/salt >> /var/www/html/wp-config.php 67 #curl https://api.wordpress.org/secret-key/1.1/salt >> /var/www/html/wp-config.php 68 echo "restart httpd service…"
[bash]http serevr部署wordpress