Thứ Ba, 1 tháng 3, 2016

Script automatically download and install WordPress on VPS

The work test and experiment VPS, it requirements regular to install WordPress source code. However, the process repeated itself quite boring so I tried to create one script auto installer saves a lot of time.


If you want to use this script to creat before a database, MySQL account, scroll to the folder to install, and then run the following command:

wget http://hocvps.com/scripts/wp && chmod +x wp && ./wp

Newest WordPress source code will be automatically downloaded, unzip.
Finally you just need access to the domain, install WordPress interface familiar will appear to you started.



Refer script:

#!/bin/bash

# Script tu dong tai ban WordPress moi nhat va cai dat tao boi Luan Tran - http://hocvps.com/

while [ 1 ];do
clear
printf "=========================================================================\n"
printf "Chuan bi qua trinh tai ban cai dat WordPress... \n"
printf "=========================================================================\n"

printf "Ban hay dien thong tin nhu yeu cau: \n"
# DB Variables
echo -n "MySQL Host (localhost): "
read mysqlhost
if [ "$mysqlhost" = "" ]; then
mysqlhost="localhost"
fi

echo -n "MySQL DB Name: "
read mysqldb

echo -n "MySQL DB User: "
read mysqluser

echo -n "MySQL Password: "
read mysqlpass

if [ "$mysqldb" != "" ] && [ "$mysqluser" != "" ] && [ "$mysqlpass" != "" ]; then
break
fi
done

clear
printf "=========================================================================\n"
printf "Downloading... \n"
printf "=========================================================================\n"

# Download latest WordPress and uncompress
wget http://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz
mv wordpress/* ./

# Grab Salt Keys
wget -O /tmp/wp.keys https://api.wordpress.org/secret-key/1.1/salt/

# Butcher our wp-config.php file
sed -e "s/localhost/"$mysqlhost"/" -e "s/database_name_here/"$mysqldb"/" -e "s/username_here/"$mysqluser"/" -e "s/password_here/"$mysqlpass"/" wp-config-sample.php > wp-config.php
sed -i '/#@-/r /tmp/wp.keys' wp-config.php
sed -i "/#@+/,/#@-/d" wp-config.php

# Tidy up
rmdir wordpress
rm latest.tar.gz
rm /tmp/wp.keys
rm wp

# Chown
if [ -f /etc/redhat-release ]; then #CentOS
 if ps ax | grep -v grep | grep 'httpd' > /dev/null; then #Apache
 chown -R apache:apache *
 elif ps ax | grep -v grep | grep 'nginx' > /dev/null; then #Nginx
 chown -R nginx:nginx *
 fi
elif [ -f /etc/lsb-release ]; then #Ubuntu
 chown -R www-data:www-data * #Both for Apache and Nginx
fi

clear
printf "=========================================================================\n"
printf "Xong, gio ban hay truy cap vao domain de cai dat WordPress! \n"
printf "Hoac truy cap http://hocvps.com \n"
printf "=========================================================================\n"

Run on CentOS and Ubuntu both.

Update: added functionality for automatic decentralization webserver.

Không có nhận xét nào:

Đăng nhận xét