Introduction

If you can automate something – do it! I was thinking about automate installing and configuring WordPress installation. I thought about writing my own tool for that but I found a ready command line tool which is great. Do you want to know how I use it?

I did not know this tool and I think is awesome. The wp-cli is extremely simple. Installation is very simple

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp

To go throw the whole installation process I need to setup the configuration. I do it with a few simple commands

cp  wp/wp-config-sample.php wp/wp-config.php
sed -ie 's/database_name_here/mysql/g' wp/wp-config.php
sed -ie 's/username_here/root/g' wp/wp-config.php
sed -ie 's/password_here/example/g' wp/wp-config.php
sed -ie 's/localhost/mysql/g' wp/wp-config.php

and when we have the database connection set up we can install the WordPress instance with one simple command

wp core install --url=localhost:8080 --title="Wordpress" --admin_user=admin --admin_password=admin-ahcker --admin_email=[email protected]

Easy, isn’t it? We set all the required data as arguments and the installation takes only a few seconds. I love it!

About the author

Bartłomiej Kiełbasa

Bartłomiej Kiełbasa

Hi! I'm Bartek. I'm a PHP developer but other languages are not scary to me. My hobby is security and I try to learn as much as it's possible how to not be hacked. I'd ike to know how things work. After hours I like playing Dota2 and watching Dragon Ball :) If you will have any question, feel free to ask.