public
Last active

Default Install Script for WordPress Setup on MAMP localhost

  • Download Gist
wp_install_default.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
#!/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.