wp cli workflow and installation script
Here’s a small shell script that I use to install WordPress locally, you will need to install wp-cli
Once you have wp-cli install simply save this script in to a file named ‘install.sh’ and ensure it lives in the folder you want to install WordPress then from the command line ‘cd’ into the folder where it lives and run ‘sh install.sh’ and follow the prompts in your terminal.
#!/bin/sh # download the core wp core download --locale=en_GB # setup the wp-config read -p "DB Name?: " -e DBNAME read -p "DB Prefix?: " -e DBPREFIX # to create the wp-config file with parameters set above # Note the dbuser and dbpass are set here for a local development setup wp config create --dbname=$DBNAME --dbuser=root --dbpass="" --dbprefix=$DBPREFIX --extra-php <<PHP define( 'WP_DEBUG', true ); define( 'DISALLOW_FILE_EDIT', true); PHP # --extra-php is just some standard stuff I like to set up with every install # creates the db using the parameters set above wp db create read -p "URL?: " -e URL read -p "Title?: " -e TITLE read -p "Admin email?: " -e ADEMAIL read -p "Admin username?: " -e ADUSERNAME read -p "Admin password?: " -e ADPASSWORD # installs WordPress using the parameters set above wp core install --url=$URL --title="$TITLE" --admin_email=$ADEMAIL --admin_user=$ADUSERNAME --admin_password=$ADPASSWORD # this is just something else I like to setup with every install, saves me having to manually set it # here you can add other options you find yourself setting everytime you install WordPress wp option update permalink_structure '/%postname%/'
This might not run on your local machine but it works in my Mac OS environment and you may need to adapt it to work on your setup.