Skip to content

Instantly share code, notes, and snippets.

@websmith
Forked from ijobling/wpinst.sh
Last active August 29, 2015 14:05
Show Gist options
  • Save websmith/258f796a87a735f710d7 to your computer and use it in GitHub Desktop.
Save websmith/258f796a87a735f710d7 to your computer and use it in GitHub Desktop.
Complete Wordpress install including all required parts, wordpress latest version, database, and config
##########################################################################
#### Script to copy install process explained in codio Wordpress Install at
### https://codio.com/s/docs/specifics/wordpress/
##########################################################################
#### Instructions
#### Option 1.
#### From the Codio Dashboard, create a new project and select the Git Tab
#### and then paste the following URL into the box
#### https://gist.github.com/cd457cf0a5efd8c483d0.git
#### Give your project a name and click Create.
### Then run the script in the terminal window by typing
### bash wpinst.sh
#### End of Instructions
##########################################################################
echo
echo " START OF AUTOMATED INSTALL"
echo
# set the hostname variable
CODIO_HOST=`cat /etc/hostname`
WORKSPACE="$HOME/workspace"
# set colour output = echo -e '\E[1;33;44m'
# remove colour = ; tput sgr0
# See http://www.tldp.org/LDP/abs/html/colorizing.html for colour codes
echo -e '\E[1;33;44m' "Download and decompress the latest version of Wordpress"; tput sgr0
wget http://wordpress.org/latest.tar.gz -O - | tar -xzvf -
echo -e '\E[1;33;44m' "Install php mysql and apache services"; tput sgr0
parts install php5 php5-apache2 php5-pdo-mysql php5-zlib mysql php5-curl php5-zip
echo -e '\E[1;33;44m' "Start the apache and mysql services"; tput sgr0
parts start apache2 mysql
echo -e '\E[1;33;44m' "Create the MySQL database that WP will use"; tput sgr0
# This script uses the default password 'password' - IT IS NOT SECURE!
echo "CREATE DATABASE wordpress;" > msqlcmds.txt
echo "USE wordpress;" >> msqlcmds.txt
echo "CREATE USER wordpressuser@localhost;" >> msqlcmds.txt
# note escaped quotes on line below
echo "SET PASSWORD FOR wordpressuser@localhost= PASSWORD(\"password\");" >> msqlcmds.txt
######################## wordpressuser ########
echo "GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';" >> msqlcmds.txt
######################## wordpressuser ########
echo "FLUSH PRIVILEGES;" >> msqlcmds.txt
echo "exit" >> msqlcmds.txt
echo The password for the MySQL server is blank!
echo You should change it after instalation.
echo -
echo For now - Just press the enter key to enter the blank password
mysql -u root -p < msqlcmds.txt -v
echo -e 'move wordpress files out of the wordpress directory and into the root.'
mv wordpress/* ./
rmdir wordpress
echo -e '\E[1;33;44m' "Create a wp-config file from the sample"; tput sgr0
cp ./wp-config-sample.php ./wp-config.php
rm wp-config-sample.php
echo -e '\E[1;33;44m' "Edit the wp-config file with username and password"; tput sgr0
sed -i "s/define('DB_NAME', 'database_name_here');/define('DB_NAME', 'wordpress');/g" $WORKSPACE/wp-config.php
sed -i "s/define('DB_USER', 'username_here');/define('DB_USER', 'wordpressuser');/g" $WORKSPACE/wp-config.php
sed -i "s/define('DB_PASSWORD', 'password_here');/define('DB_PASSWORD', 'password');/g" $WORKSPACE/wp-config.php
########################### wordpressuser ########
echo -e '\E[1;33;44m' "Set WP for codio domain names"; tput sgr0
sed -i "36i define('WP_HOME','http://WORD1-WORD2.codio.io:3000/');" $WORKSPACE/wp-config.php
sed -i "37i define('WP_SITEURL','http://WORD1-WORD2.codio.io:3000/');" $WORKSPACE/wp-config.php
sed -i s_WORD1-WORD2_"$CODIO_HOST"_g $WORKSPACE/wp-config.php
echo -e '\E[1;33;44m' "Delete install files"; tput sgr0
rm msqlcmds.txt
rm wpinst.sh
echo -e '\E[1;33;44m' "Preview - Setup Menu - editing .codio file"; tput sgr0
echo '
{
"commands": {
"PHP Version": "php --version"
},
"preview": {
"WordPress Site": "http://{{domain}}:3000/",
"WordPress Admin": "http://{{domain}}:3000/wp-admin"
}
}' > ~/workspace/.codio
echo -e '\E[1;33;44m' "Setting up Autostart of services file"; tput sgr0
echo '
parts stop apache2 mysql
parts start apache2 mysql
' > ~/workspace/startup.sh
echo
echo
echo -e '\E[1;37;44m'" .......Wordpress Installed!"; tput sgr0
echo -
echo "- Two MySQL accounts have been created which"
echo "are not secure and should be changed;"
echo
echo 1. The MySQL admin account:
echo username=root, password is blank
echo
echo 2. The MySQL account used by Wordpress:
echo username=wordpressuser, password=password
echo -
echo "You may now use Wordpress itself to complete the setup."
echo "Once in Wordpress you will be asked to create the"
echo "first Wordpress user and then login as that user."
echo
echo -
echo "To get to your Wordpress site, open your browser and go to -"
echo
echo " http://"$CODIO_HOST".codio.io:3000/wp-admin"
echo
echo "or"
echo
echo " http://"$CODIO_HOST".codio.io:3000/login.php"
echo
echo "or"
echo On the Preview menu, that is the right most Codio menu,
echo from the drop down menu, select WordPress Login or WordPress Admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment