WordPress Installer

WordPress Installer

This is my biggest bash script yet! It will fully install WordPress from a shell command and add a number of security measures to boot.

It allows you to enter the database connection details, downloads the latest version in your language, file and directory permissions are sorted, it handles the random keys,  all the basic WordPress administrator information (if you have WP Cli installed) and a few other things.

  • Install and update WordPress in your own language to web root or a sub directory
  • Handles file and directory permissions
  • Removes licence.txt and readme.html
  • Checks for a working database connection
  • Adds a random database prefix
  • Generates random username and password for administrators
  • Set the maximum upload and post limits
  • Creates the .htaccess to allow for URL rewriting, adds browser caching and some basic security measures
  • Uninstall functionality
  • Besides the setup part, this will install WordPress without requiring WP-Cli

It is simple to use, to install a new WordPress website run:

The arguments in square brackets are optional, you just need the username as a minimum. To uninstall (remove all files and reset the website) an existing installation use:

Please have a look at my automatic WordPress update script if you like to set up regular updates using WP-Cli. In a future version of this script, I’ll make the arguments easier to set and include all the inputs needed for the WP-Cli setup.

If you’re adding this to your server, I’d recommend taking the opportunity to add a few of your favourite plugins as follows:

Insert this after the wp core install line and edit this to use your plugin names and locations.

Please send me your suggestions and I’ll update the script if you have some good ideas!

Update on 5th November 2018: Added a check for a working MySQL connection before attempting to install WordPress. Previously, a bad database connection broke the installation process.

Leave a Reply

Your email address will not be published.