Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Auto Install Latest WordPress from Shell
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost
echo "MySQL DB Name:"
read mysqldb
export mysqldb
echo "MySQL DB User:"
read mysqluser
export mysqluser
echo "MySQL Password:"
read mysqlpass
export mysqlpass
# WP Variables
echo "Site Title:"
read wptitle
export wptitle
echo "Admin Username:"
read wpuser
export wpuser
echo "Admin Password:"
read wppass
export wppass
echo "Admin Email"
read wpemail
export wpemail
# Site Variables
echo "Site URL (ie, www.youraddress.com):"
read siteurl
export siteurl
# Download latest WordPress and uncompress
wget http://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz
mv wordpress/* ./
# Grab our 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
# Run our install ...
curl -d "weblog_title=$wptitle&user_name=$wpuser&admin_password=$wppass&admin_password2=$wppass&admin_email=$wpemail" http://$siteurl/wp-admin/install.php?step=2
# Tidy up
rmdir wordpress
rm latest.tar.gz
rm /tmp/wp.keys
Copy link

ghost commented Apr 2, 2015

i think you have made an error in your script. i think you should write wget --post-data instead of curl -d. When testing out your script it didn't work with curl -d so i made the edit and then it is working just fine.

@VadimChorrny
Copy link

VadimChorrny commented Oct 31, 2020

wow, thanks!
change please --date

@hAbd0u
Copy link

hAbd0u commented Mar 13, 2021

You saved me time to research the form submitting.

@filipe-jsales
Copy link

filipe-jsales commented Oct 23, 2022

thank you, saved me time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment