← All posts

Fixing WordPress on Google Cloud: Disk Space, Inodes, Database Errors and PHP

A while ago, I wrote a brief guide to some common errors with WordPress Multisite on Google Cloud Platform. Since then, I’ve encountered a few more issues running WordPress and WooCommerce on a Google Compute Engine VM, using OpenLiteSpeed and Cloud SQL.

Here are four problems, how I diagnosed them, and the fixes.

1. VM running out of disk space

Our Compute Engine VM has a relatively small root disk, around 10GB. Over time, disk usage started creeping up.

First, check disk usage:

df -h

To find where the space is being used, inspect the largest directories:

sudo du -h -x --max-depth=1 /var | sort -h

In our case, the largest were:

3.6G    /var/lib
1.1G    /var/www
857M    /var/log
134M    /var/cache

Drilling further into /var/lib:

sudo du -h -x --max-depth=1 /var/lib | sort -h

Revealed:

3.1G    /var/lib/snapd
256M    /var/lib/apt
190M    /var/lib/mysql

Snap was consuming a substantial proportion of our disk. This can happen when old Snap revisions are retained after upgrades.

The fix

First, inspect installed Snap packages and their revisions:

snap list --all

Remove old, disabled revisions where they’re no longer required:

snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
  sudo snap remove "$snapname" --revision="$revision"
done

You can also reduce how many revisions Snap retains:

sudo snap set system refresh.retain=2

Check the logs too:

sudo journalctl --disk-usage

If historical systemd journal logs are consuming excessive space, you can trim them:

sudo journalctl --vacuum-size=200M

Finally, check the difference:

df -h

These are targeted cleanup options rather than a record of every command we executed. Inspect which Snap revisions and logs are safe to remove before running them on production.

2. No space left on device, despite having free disk space

We later encountered a more confusing problem. WordPress became unresponsive, and services started failing with filesystem errors. But df -h showed that the disk wasn’t full.

The issue turned out to be inode exhaustion.

Every file consumes an inode, regardless of how small it is. A filesystem can have free storage but no remaining capacity to create files.

Diagnose it:

df -i

Our root filesystem showed:

Filesystem   Inodes    IUsed     IFree  IUse%
/dev/root    1290240   1290240   0      100%

Find which directories contain the most files:

sudo du --inodes -x --max-depth=1 / | sort -n

Then investigate the likely directories:

sudo du --inodes --max-depth=1 /tmp | sort -n

We found over a million PHP session files in /tmp, named sess_*.

The immediate fix

First, count the session files:

sudo find /tmp -maxdepth 1 -type f -name 'sess_*' | wc -l

Then count those older than seven days:

sudo find /tmp -maxdepth 1 -type f -name 'sess_*' -mmin +10080 | wc -l

If these are expired sessions that your application no longer needs, remove them:

sudo find /tmp -maxdepth 1 -type f -name 'sess_*' -mmin +10080 -delete

We initially cleared the accumulated old sessions, bringing inode usage back down to around 10%.

Prevent it happening again

Our LiteSpeed PHP configuration had automatic session garbage collection disabled:

session.gc_probability = 0

Ubuntu’s standard PHP session cleanup service wasn’t cleaning the LiteSpeed-generated files.

We added a cron job:

sudo nano /etc/cron.d/lsphp-session-cleanup

With the following content:

17 * * * * root /usr/bin/find /tmp /var/lib/php/sessions -maxdepth 1 -type f -name "sess_*" -mmin +10080 -delete

This removes PHP session files older than seven days, every hour, from both session directories.

Check that cron is running:

systemctl is-active cron

And monitor inode usage:

df -i

Seven days was a conservative retention choice for our installation, not a universal PHP session lifetime. Make sure your cleanup policy matches your application’s session requirements and doesn’t inadvertently remove sessions belonging to another application.

3. WordPress: Error establishing a database connection

Another outage left WordPress unable to connect to its Cloud SQL database.

Ordinarily, this error might mean incorrect credentials, a stopped database, or a network configuration problem.

Check database connectivity from the VM:

nc -vz -w 5 YOUR_CLOUD_SQL_IP 3306

If the connection times out, check whether the database is running and whether the VM can reach it.

For Cloud SQL, you can inspect the instance through Google Cloud Console or the CLI:

gcloud sql instances describe YOUR_INSTANCE_NAME

We tried restarting the VM, but the database connection continued to time out. Restarting Cloud SQL also failed with an internal error.

The fix

In this case, there was no configuration fix on our side.

Google Cloud was experiencing a regional outage affecting services in europe-west2 (London), including Cloud SQL.

The correct response was to check Google Cloud Service Health, confirm the incident, and wait for the underlying service to recover rather than repeatedly restarting or reconfiguring healthy components.

If Cloud SQL is healthy and no provider incident is reported, the next checks would be its connection settings, private networking, firewall rules and database credentials.

4. Upgrading OpenLiteSpeed PHP after critical security vulnerabilities

In October 2026, PHP announced two critical remote code execution vulnerabilities, CVE-2026-109618 and CVE-2026-109619.

Our OpenLiteSpeed server was running PHP 8.1.27, which was no longer supported by the PHP project.

We needed to upgrade to a patched version without breaking WordPress or WooCommerce.

Check the current PHP version:

/usr/local/lsws/lsphp81/bin/php -v

For OpenLiteSpeed, also check the active PHP handler:

sudo grep -n 'path.*lsphp' /usr/local/lsws/conf/httpd_config.conf

Our handler pointed to:

path lsphp81/bin/lsphp

Install a patched PHP release

Check the available LiteSpeed packages:

sudo apt update
apt-cache policy lsphp84

Our repository offered PHP 8.4.27, which contained the fixes.

After taking backups, we installed it alongside PHP 8.1:

sudo apt install \
  lsphp84 \
  lsphp84-common \
  lsphp84-mysql \
  lsphp84-curl \
  lsphp84-imagick \
  lsphp84-intl \
  lsphp84-opcache \
  lsphp84-redis \
  lsphp84-memcached \
  lsphp84-imap \
  lsphp84-igbinary \
  lsphp84-msgpack

Check the new version and extensions:

/usr/local/lsws/lsphp84/bin/php -v
/usr/local/lsws/lsphp84/bin/php -m

Compare PHP configuration

New PHP installations don’t necessarily inherit the old configuration.

Our PHP 8.4 installation initially had a 128MB memory limit and a 2MB upload limit, compared with 256MB for both on the old installation.

We updated:

/usr/local/lsws/lsphp84/etc/php/8.4/litespeed/php.ini

To use:

memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 24M
session.upload_progress.enabled = 0

These values suited our intended setup but may need adjusting for larger uploads or imports.

Switch the OpenLiteSpeed handler

Back up the configuration:

sudo cp -a \
  /usr/local/lsws/conf/httpd_config.conf \
  /usr/local/lsws/conf/httpd_config.conf.pre-php84

Change the PHP executable path:

sudo sed -i \
  's|path                    lsphp81/bin/lsphp|path                    lsphp84/bin/lsphp|' \
  /usr/local/lsws/conf/httpd_config.conf

Validate:

sudo /usr/local/lsws/bin/openlitespeed -t

Then restart:

sudo systemctl restart lsws
sudo systemctl is-active lsws

Verify the running PHP version

One slightly confusing detail: OpenLiteSpeed’s PHP workers often appear simply as lsphp, without the version number.

To find which binary they’re actually running:

for pid in $(pgrep -x lsphp); do
  echo "PID $pid: $(sudo readlink -f /proc/$pid/exe)"
done

Our active workers now pointed to:

/usr/local/lsws/lsphp84/bin/lsphp

Finally, check the PHP version under WordPress Tools → Site Health → Info → Server, and test WooCommerce product pages, baskets and checkout for compatibility.

If anything goes wrong, the original handler configuration can be restored from the backup and OpenLiteSpeed restarted. Returning to vulnerable PHP 8.1 should only be a temporary emergency measure.


These fixes are specific to our setup — Ubuntu 22.04, Google Compute Engine, Cloud SQL, OpenLiteSpeed and WooCommerce — but the diagnostic commands should be useful for other Linux-hosted WordPress installations too.

More to read

See all

Comments

Loading comments…

Not published. Required for moderation.