Rig an Ubuntu VM for WordPress plugin development

These are my rough notes on the steps needed to set up a VM to do WordPress development with PhpStorm.

Create the VM

Download the Ubuntu .iso file and create a VM using your virtualization program. Give the VM at least 6GiB of RAM and two processors to work with. For best results give it a 100GiB virtual hard drive. Give it a bridged network adapter.

You should install the basic Ubuntu desktop, unless you want all the apps and games and other (cough) bloatware.

First setup steps

Log in. Let’s say your username, throughout, is pluginhacker.

As root, give this command so you don’t have to give your password every time you say sudo.

echo "pluginhacker ALL=(ALL:ALL) NOPASSWD:ALL" >/etc/sudoers.d/pluginhacker

Back in your regular account do these things

sudo apt update
sudo apt -y install ssh-import-id build-essential git
sudo apt -y install vim net-tools htop mariadb-server
sudo apt -y install php libapache2-mod-php php-mysqli php7.4-xdebug
sudo apt -y install php-gd php-intl php-curl php-imagick php-mbstring
sudo apt -y install php-zip php-xml php-redis php-bcmath php-apcu
sudo a2enmod rewrite 
sudo apachectl restart

Configure MariaDB

sudo mysql_secure_installation
sudo mariadb
GRANT ALL ON *.* TO 'pluginhacker'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'pluginhacker'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

Then rig MariaDB so you can connect to it via TCP/IP. You’ll edit its server configuration and insert the line bind-address =

sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
# (do the editing and save the file)
sudo service mysql restart

Then you can try connecting with mysql -u pluginhacker -p to make sure you have it right.

Install PhpStorm

(You need a JetBrains license for this. Personal licenses can be had for short money.)

Visit https://www.jetbrains.com/toolbox-app/ with a browser and download the toolbox code. Then run the toolbox.

sudo tar -xzf Dowhnloads/jetbrains-toolbox-1.17.7391.tar.gz -C /opt

Use the toolbox to install PhpStorm and run it.

Set up a virtual host for your web server

Let’s say you want a virtual host called myplugin.example.com. Use ip -4 addr to determine your machine’s IP address. Add that address to your DNS for your domain. It’s OK to add private network addresses to DNS.

Then make your VM’s hostname match the virtual host you want.

sudo vi /etc/hostname   # set the hostname in the hostname file
sudo hosthame myplugin.example.com 

You then create the file /etc/apache2/sites-available/myplugin.example.com.conf. It has this in it.

<VirtualHost *:80>
    ServerName myplugin.example.com
    ServerAlias www.myplugin.example.com
    ServerAdmin your-email-here
    DocumentRoot /var/www/myplugin.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/myplugin.example.com>
      Options Indexes FollowSymLinks
      AllowOverride All

Then create the directory /var/www/myplugin.example.com and put the WordPress code into it.

cd /var/www
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mkdir myplugin.example.com
sudo mv wordpress/* myplugin.example.com/
sudo chown -R www-data:www-data myplugin.example.com
sudo find myplugin.example.com -type d -exec chmod go+rwx {} \;
sudo find myplugin.example.com -type f -exec chmod go+rw {} \;

Next, tell the apache web server to serve the virtual host just set up.

cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/myplugin.example.com.conf
sudo apachectl restart

Install WordPress

We already created a database called “wordpress`. So all we need to do now is visit


and follow the directions.

Set up the plugin development directory

Let’s say you want your plugin source code in ~/src/myplugin. Create those directories and put your plugin there. You may use git to do that.

Then, create a symbolic link to your source code within your WordPress installation.

cd /var/www/myplugin.example.com
cd wp-content/plugins
sudo ln -s ~/src/myplugin
sudo chown --no-dereference www-data:www-data myplugin

Install wp-cli

cd ~
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar –info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info
cd /var/www/myplugin.example.com
wp core version
wp package install wp-cli/dist-archive-command

Enable debugging

Do this to set configuration variables in wp-config.php.

wp config set WP_DEBUG true --raw
wp config set WP_ALLOW_MULTISITE true -- raw  # if you might use multisite
wp plugin install query-monitor --activate # if you want the Query Monitor plugin
wp plugin install debug-bar --activate # if you want the Debug Bar plugin

Update your Ubuntu software

cd ~
sudo apt update && sudo apt -y upgrade && sudo apt -y autoremove

Leave a Comment