Skip to content

Instantly share code, notes, and snippets.

@i3inary
Created April 3, 2012 22:55
Show Gist options
  • Save i3inary/2296125 to your computer and use it in GitHub Desktop.
Save i3inary/2296125 to your computer and use it in GitHub Desktop.
Default Install Script for WordPress Setup on MAMP localhost
#!/bin/bash
##############################
# DEFAULT WORDPRESS AND PLUGIN INSTALL SCRIPT
#
# 2012-04-03
# 1.0
# TODO: PUT A YES/NO PROMPT BEFORE RUNNING SCRIPT
#!!!!! EXITS UNLESS YOU MANUALLY COMMENT OUT THE LINE BELOW
exit
################
# VARIABLES/ARGUMENTS
################
# information for install
domain_name="testdomain.com"
www_root_dir="$domain_name"
db_name="testdomain"
db_user="testdomain"
db_pass="123456"
################
# CLEANUP/FORMATTING
################
# make sure mysql user is 14 char or less
db_user=$(echo "$db_user" | cut -c -14)
################
# WORDPRESS
################
echo "** DOWNLOADING WORDPRESS **"
echo ""
# get latest wordpress source
cd ~/Source/WordPress/_latest/
rm -rf wordpress
curl -L -o 'latest.tar.gz' http://wordpress.org/latest.tar.gz
tar -zxf latest.tar.gz wordpress
echo "** COPYING WORDPRESS FILES **"
echo ""
# copy latest source to target local www root folder
mkdir /Applications/MAMP/htdocs/$www_root_dir
cp -R wordpress/* /Applications/MAMP/htdocs/$www_root_dir
echo "** COPYING DEFAULT.COM PLUGINS **"
echo ""
# copy standard plugins from default installation
cp -R /Applications/MAMP/htdocs/_default_install/wp-content/plugins/* /Applications/MAMP/htdocs/$www_root_dir/wp-content/plugins
echo "** CREATING WP-CONFIG.PHP FILE **"
echo ""
# review config file for default install
cd /Applications/MAMP/htdocs/$www_root_dir
mv wp-config-sample.php wp-config.php
echo "** WP-CONFIG INFO TO USE **"
echo ""
echo "DB NAME: $db_name"
echo "DB USER: $db_user"
echo "DB PASS: $db_pass"
# launch textmate to edit config file
mate wp-config.php
################
# MYSQL
################
# create sql commands for local database & user
qry_create_db="CREATE DATABASE \`$db_name\`;"
qry_grant_user="GRANT ALL ON \`$db_name\`.* TO '$db_user'@'localhost';"
qry_create_user="SET PASSWORD FOR '$db_user'@'localhost' = PASSWORD('$db_pass');"
qry_flush="FLUSH PRIVILEGES;"
# create sql statement
SQL="${qry_create_db}${qry_grant_user}${qry_create_user}${qry_flush}"
echo "** CREATING WORDPRESS DATABASE FROM ARGS **"
echo ""
echo $SQL
echo ""
# execute mysql commands
/Applications/MAMP/Library/bin/mysql -uroot -proot -e "$SQL"
################
# APACHE
################
echo "** CONFIGURE APACHE **"
echo ""
# add to httpd_conf
~/Source/scripts/httpd_vhost.sh $domain_name >> /Applications/MAMP/conf/apache/httpd.conf
echo "** RESTART APACHE **"
echo ""
# restart httpd service
sudo /Applications/MAMP/bin/apache2/bin/apachectl restart
################
# LOCAL MACHINE
################
echo "** CONFIGURE HOSTS FILE **"
echo ""
# add domain mapping to local hosts file
sudo echo "127.0.0.1 $domain_name #hide" >> /etc/hosts
mate /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment