Last active
May 15, 2018 14:04
-
-
Save ijobling/cd457cf0a5efd8c483d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################## | |
#### 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. | |
#### Option 2. | |
#### From the Codio Dashboard, create a new Empty template project. | |
#### Open a Terminal window from the Tools->Terminal window | |
#### Copy the contents of this file to a file called 'wpinst.sh' in the root of your machines file system | |
### 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 | |
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 '\E[1;33;44m' "Create a wp-config file from the sample"; tput sgr0 | |
cp ./wordpress/wp-config-sample.php ./wordpress/wp-config.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/wordpress/wp-config.php | |
sed -i "s/define('DB_USER', 'username_here');/define('DB_USER', 'wordpressuser');/g" $WORKSPACE/wordpress/wp-config.php | |
sed -i "s/define('DB_PASSWORD', 'password_here');/define('DB_PASSWORD', 'password');/g" $WORKSPACE/wordpress/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-3000.codio.io/wordpress');" $WORKSPACE/wordpress/wp-config.php | |
sed -i "37i define('WP_SITEURL','http://WORD1-WORD2-3000.codio.io:/wordpress');" $WORKSPACE/wordpress/wp-config.php | |
sed -i s_WORD1-WORD2_"$CODIO_HOST"_g $WORKSPACE/wordpress/wp-config.php | |
echo -e '\E[1;33;44m' "Download the plugin that allows for Wordpress to work properly on codio"; tput sgr0 | |
wget http://downloads.wordpress.org/plugin/permalink-fix-disable-canonical-redirects-pack.1.0.3.zip | |
echo -e '\E[1;33;44m' "Install plugin"; tput sgr0 | |
unzip permalink-fix-disable-canonical-redirects-pack.1.0.3.zip -d $WORKSPACE/wordpress/wp-content/plugins | |
echo -e '\E[1;33;44m' "Delete install files"; tput sgr0 | |
rm permalink-fix-disable-canonical-redirects-pack.1.0.3.zip | |
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 Login": "https://{{domain3000}}/wordpress/wp-login.php", | |
"WordPress Admin": "https://{{domain3000}}/wordpress/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 "Once logged in you should go to the plugins page and" | |
echo "enable an instaled plugin called - " | |
echo | |
echo " permalink-fix-disable-canonical-redirects" | |
echo | |
echo "which is necessary for Wordpress to work correctly on codio." | |
echo - | |
echo "To get to your Wordpress site, open your browser and go to -" | |
echo | |
echo " http://"$CODIO_HOST".codio.io:3000/wordpress/wp-admin" | |
echo | |
echo "or" | |
echo | |
echo " http://"$CODIO_HOST".codio.io:3000/wordpress/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