Testing on Ubuntu 18 and PHP 7

Last Revised: October 2, 2021

If you want to test in a development environment (without sending the data), you can do it without problem. The goal of this test is to work with multiple options and configurations, with the ultimate goal of finding the best environment to work with.


Although there are no minimum requirements in themselves, in the tests I have been able to do I have found that, at least, it is recommended:

  • VPS (you can also use an on-premises environment)
    • 1 CPU
    • 2 GB RAM
    • 10 GB SSD
  • Ubuntu, CentOS, Debian…
    • Ubuntu 18.04 LTE
  • MySQL, MariaDB, Percona for MySQL
    • MariaDB 10.4
  • PHP
    • PHP 7.4

Keep in mind that this example does not pose a machine in production, but an example of different elements and tests that can be executed, counting the installation of cache systems, PHP extensions …

This tutorial has been created on a Clouding.io VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.


Base installation

The base installation proposes to arrange the minimum elements for the system to work.

Operating System Configuration

The first thing we will do is put the system on time. To avoid problems and taking into account that it can be a machine that sends information to WordPress, it would be best to configure the clock in UTC mode universally.

timedatectl set-timezone UTC
timedatectl set-ntp on

The next thing we will do is bring the machine up to date on your entire system. With this we will ensure that everything is up to date and that conflicts are reduced to a minimum.

apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove

We will install some necessary and common tools such as curl, vim, zip or the git itself.

apt -y install software-properties-common curl vim unzip git

Installing the database

We will install MariaDB 10.4 in the trial. In principle, any database compatible with WordPress serves.

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.4"
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install mariadb-server mariadb-client
systemctl restart mysql.service

Once the installation is finished, we will make a first configuration to leave it ready.


From this moment the system will ask us a series of questions and we will configure the root password of the database itself.

Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

We will restart the database so that it takes all the data and leaves the system ready.

systemctl restart mysql.service

Installing PHP

For this test we will install PHP 7.4. At first we are only going to install the minimum elements, so we will surely have to expand later with some extensions. As I said at the beginning, the goal is to test the system, so at this time it makes sense that it gives us error due to lack of elements.

add-apt-repository -y ppa:ondrej/php
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install php7.4 php7.4-curl php7.4-dev php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-mysqlnd
apt -y install php-pear pkg-config
pecl channel-update pecl.php.net

Although we can leave the PHP configuration as we have it in the usual system that is offered to customers, for this test we will make some small changes.

vim /etc/php/7.4/fpm/php.ini

And we will change these settings.

max_execution_time = 60
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = 'UTC'

Once the reconfiguration is finished, we will restart the service and activate it by default.

systemctl stop php7.4-fpm.service
systemctl enable php7.4-fpm.service
systemctl start php7.4-fpm.service

Installing Node

For the tests to work correctly we will need some elements that may not usually be available. Among them etsá NodeJS, Grunt and PhantomJS.

First we install NodeJS

curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install nodejs

Later we installed Grunt

npm install -g grunt

And finally we install phantomJS

apt -y install build-essential chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
rm -rf phantomjs-2.1.1-linux-x86_64.tar.bz2

Completing setup

To finish the configuration of the machine, we will make some adjustments. To begin with, we will update everything again and make sure that no library has been left hanging.

apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove

And we will configure the test database that we are going to use in the tests. We will enter the server.

mysql -u root -p

And we will create a test database. In this case it will wordpress be called and the user will also be wordpress. Set the password you see fit.

CREATE DATABASE wordpress CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin;
GRANT ALL ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '__PASSWORD__';
GRANT ALL ON wordpress.* TO 'wordpress'@'' IDENTIFIED BY '__PASSWORD__';

From this moment we have all the basis to be able to do our first test.

Installing the PHPUnit test

We will follow the instructions we have previously had. By default we will do the tests in the folder /tmp/.

cd /home/
git clone https://github.com/WordPress/phpunit-test-runner.git
cd /home/phpunit-test-runner/
cp .env.default .env

And we will establish the contents of the environment with the access data that we have previously created.

vim .env

Remember to include the folder where the software is installed and where the WordPress will be installed, in addition to the access data to the database.

export WPT_PREPARE_DIR=/home/wp-test-runner
export WPT_TEST_DIR=/home/wp-test-runner
export WPT_DB_NAME=wordpress
export WPT_DB_USER=wordpress
export WPT_DB_HOST=localhost
export WPT_DEBUG=

Preparing the environment

Before doing the first test, we will update everything. This process can be executed before doing each test in this environment if we want to have it up to date, although it will depend more if it is in a production environment.

apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
cd /home/phpunit-test-runner/
git pull
npm update
source .env

Preparing the test

Now that we have the environment ready, we can run the test preparation.

cd /tmp/phpunit-test-runner/
php prepare.php

The system will run a long series of installations, configurations and compilations of different elements to be able to prepare the test. If warnings and warnings come out you should not worry much, since it is quite normal. At the end of the process it will let you know if you need something you don’t have. In principle, there should be something such that this:

Replacing variables in wp-tests-config.php
Success: Prepared environment.

If the environment has been prepared, the next step is to do a first test.

Running the test

Now that we have the environment ready, let’s go for the test. To do this we will execute the file that will make it.

cd /home/phpunit-test-runner/
php test.php

What do the symbols mean?

  • .: Each point means that the test has been passed correctly.
  • S: It means that the test has been skipped. It is usually because these tests are only valid in certain configurations.
  • F: It means that the test has failed. At the end there is information about why.
  • E: It means that the test has failed due to a PHP error, which can be error, warning or notice.
  • I: Means that the test has been marked as incomplete.

If you have followed all the steps up to this point it is very likely that the test you have run will fail a lot (for example, because by default you will not be able to do the image processing). But nothing happens, as I said, this is an example to check and verify the operation.

Creating a report

Even if the test has failed, we can generate the report and (if applicable) send it. But first things first, which is the creation of the reports. To do this we will execute the file that does it.

cd /home/phpunit-test-runner/
php report.php

This system will generate the two files that are sent as reports.

In the first of them we can see the information about our environment.

cat /home/wp-test-runner/env.json

The content of this file is somewhat similar to this:

    "php_version": "7.4.5",
    "php_modules": {
        "bcmath": false,
        "curl": "7.4.5",
        "filter": "7.4.5",
        "gd": false,
        "libsodium": false,
        "mcrypt": false,
        "mod_xml": false,
        "mysqli": "7.4.5",
        "imagick": false,
        "pcre": "7.4.5",
        "xml": "7.4.5",
        "xmlreader": "7.4.5",
        "zlib": "7.4.5"
    "system_utils": {
        "curl": "7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1g zlib/1.2.11 libidn2/2.3.0 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3",
        "ghostscript": "",
        "imagemagick": false,
        "openssl": "1.1.1g  21 Apr 2020"
    "mysql_version": "mysql  Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2",
    "os_name": "Linux",
    "os_version": "4.15.0-20-generic"

As you can see, among the most prominent elements are the extensions that are usually used in WordPress and some utilities that as a general rule are also useful.

The other file is the one that includes all the tests that are carried out (more than 10,000) giving information on the time they take to execute, problems that may have arisen …

cat /home/wp-test-runner/junit.xml

Cleaning up the environment for further testing

Now that we have the tests working, what we have left to do is delete all the files that have been created to be able to start over. To do this we will execute the following command:

cd /home/phpunit-test-runner/
php cleanup.php

About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.