Bash script to configure MySQL database and install WordPress

Updated 4/6/15 – now with added key/salt generation

When deploying a new WordPress site, there are two (potentially) needlessly time-consuming steps – logging in to MySQL to setup a new database and user, and then copying the WordPress files to the directory. The script below lets you do this in one step, pass in your database and basic WordPress settings, and it will configure MySQL and directly download WordPress to the server. A key benefit of this over a phpMyAdmin + FTP approach is that it will work over even ropey internet connections as the work is all done on the server itself.

A more advanced approach is to build a setup script based on WP-CLI, which allows the most customisation, but also needs more setup work and control over the server. If you always install the same plugins and themes – definitely look in to this.

How to use the script:

  1. SSH in to your server and navigate to the desired install directory (e.g. /var/www/domain/)
  2. Paste all of the following in to terminal and hit Return:
    curl -L -o 'wp.sh' https://gist.githubusercontent.com/emirpprime/37ef1f355ec5a7ecbb8f/raw/019acd595af695498acdf7b497e32ca0ebfb87f0/wp.sh && bash wp.sh
  3. Enter your details when prompted
  4. (Exit / close the SSH connection, your done here)
  5. Navigate to your new site in a web browser to complete the normal WordPress installation steps

Here’s the raw script so you can see what it’s doing – feel free to Fork it or suggest improvements:

Category:

Tags:

5 responses to “Bash script to configure MySQL database and install WordPress”

  1. Mi Weickum avatar
    Mi Weickum

    Really great site bro, i really apreciate your work! I save this site in my bookmarks.

  2. Pawel avatar
    Pawel

    Very good script!

  3. Aman avatar

    I have created a bash script to automate the installation of WordPress , Plugins and themes also. You can find script on github.com
    https://github.com/jeoga/wordpress_install_bash_script

    1. Phil Banks avatar

      Looks good 🙂 Nice git integration.

  4. Wordpress Developer avatar

    Nice tutorial! This is really helpful to used my business site development. It is simple and easy to understand. It is saved lot of time. Great work.

    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *