Insta WordPress dev server with WP-CLI

Publié le 30 juin 2016

Important note: I’m using Ubuntu 16.04 as of writing this post.

Recently, I started studying in order to contribute to WordPress core. One of my first challenge was to setup a development environment. After using and contributing to vagrantpress I learned there was a way to use WP-CLI to spawn a local PHP server.

While there are numerous benefits of using a VM to develop software, I still dislike it. It’s slower than the host, it’s complicated to modify and you have to download tons of softwares with bugs and quirks. Call me old fashioned but installing Apache and MySQL on my computer was way easier for me. Also, using configured VMs doesn’t teach you about software usage.

How to get things working

Install MariaDB (not MySQL) `sudo apt-get install mariadb-client mariadb-server`.

Install WP-CLI (official doc).

Install PHP `sudo apt-get install php`.

Bash magic wand that spawn servers

    echo "Make sure your SQL server is running then press [ENTER]"
    read whatever
    mkdir instawp_src
    cd instawp_src
    wp core download
    wp core config --dbname=wordpress --dbuser=wordpres
    wp core install --url=localhost --title=test --admin_user=admin \
                    --admin_password=admin [email protected]
    echo "To clean up run \`rm -fr ${current_dir}/instawp_src\`"
    wp server

That’s it!