My WordPress Development Environment

My WordPress Development Environment

Here’s how I set up Valet for Linux—which, in my opinion, beats both VVV and XAMPP—and the rest of my development environment.

The Basis

My development environment is a fresh Xubuntu 18.04 install. I’ve also just installed PHP, cURL and MySQL:

sudo apt-get install curl
sudo apt-get install php7.2
sudo apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml
sudo apt-get install mysql-server

Sometime during the MySQL install, it should ask to enter a password for the ‘root’ user. (Please do so.)

Note: If it doesn’t, there are a few ways to reset the root password without actually having access to it. Unfortunately, these haven’t always worked for me. This solution over at Stack Overflow, however, explains setting the root password before installing MySQL, and should just work.

Installing Composer (a PHP package and dependencies manager) isn’t exactly rocket science, either. In brief:

sudo apt-get install composer

If you’d rather install the latest version rather than the one Ubuntu happens to ship, feel free to manually download the PHAR file instead.

Valet: My PHP Development Environment of Choice

I really like Valet for Linux, rather than VVV—which has too often failed me before—or XAMPP—too limited, really.

cd
composer global require cpriego/valet-linux

valet install, unfortunately, won’t work unless I first get rid of Apache, and install some required packages:

sudo apt-get ---purge remove apache2*
sudo apt-get install network-manager libnss3-tools jq xsel
valet install

I like dropping my sites in a directory I call Sites—I know!

cd
mkdir Sites
cd Sites
valet park

Extra: phpMyAdmin

Since I’m not as familiar with command-line SQL as I probably should, I’m installing phpMyAdmin, too:

cd ~/Sites
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
unzip phpMyAdmin-latest-all-languages.zip
mv phpMyAdmin-*-all-languages/ phpmyadmin

Yep. That’s literally all it takes to get phpMyAdmin up and running at http://phpmyadmin.test. I log in with ‘root’ and my previously chosen password, and create a new database, like wordpress.

Note: A few databases in, you may want to up PHP’s memory limit in order to be able to use phpMyAdmin without server errors. On Ubuntu, Valet’s php.ini can be found in /etc/php/7.2/fpm/. Setting memory_limit to 1024M—1 GB—will probably do.

WordPress

WP-CLI is a command line utility that’s installed as follows and helps greatly speed up certain WordPress actions …

cd
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
echo 'alias wp="~/wp-cli.phar"' >> ~/.bashrc
source ~/.bashrc

… like downloading the core WordPress files:

cd ~/Sites
mkdir janboddez
cd janboddez
wp core download

Finally, at http://janboddez.test, I’m confronted with WordPress’s “famous five-minute installation” guide!