Community-driven coverage of elementary OS — news, guides & forums
Dark abstract low-poly geometric landscape with layered triangular facets in deep navy, charcoal, and muted teal, illuminated by a soft electric-blue glow near the horizon

News roundups, tutorials, application guides, and forums — built by users, for users of the elegant Linux distribution.

elementary weekly
#20
Latest roundup · 18 Apr 2015
Freya Release
Final
Covered in weekly #19 & #20
Forum Topics
Active
Installation, customization & more

Build a Local WordPress Development Environment on elementary OS

Building a theme or a plugin for WordPress means shipping code that has to survive contact with real content, real plugins and real server settings. The safest way to find those problems is to work on a copy of the site that lives on your own machine, where you can delete a database without a support ticket and where a broken build costs nothing but a restart. elementary OS suits that job well, because it sits on Ubuntu's package base while keeping a clean, approachable desktop around it. This guide covers setting up a local WordPress development environment on elementary OS from first update to a working site you can rebuild whenever you like.

A local stack also removes the monthly cost of a hosted staging box. Services such as Pantheon or a managed development environment are handy for team workflows, but a solo builder or a small agency in Australia can cover the same ground with Apache, MariaDB and PHP, all available through the standard repositories. There is no credit card to enter, no GST on a subscription to reconcile, and no build sitting on a data centre in another hemisphere.

The speed difference matters more than it sounds. With everything on localhost, a browser refresh is a fraction of a second, and PHP error logs appear in a terminal window rather than an email from a support desk. That tight loop is the whole point: change a line of code, reload, read the error, fix it, repeat. The rest of this walkthrough assumes a reasonably recent release of elementary OS and a comfortable command line, though every command is explained as it appears.

Why a local WordPress build belongs on your desk

The main argument for local work is that it decouples experimentation from the site your visitors actually see. You can install a plugin that rewrites post slugs, run a bulk import of three thousand posts, or switch to a different PHP version without worrying that somebody's live checkout will break mid-purchase. On a local install, the worst outcome is a database you drop and recreate from a dump.

Local environments also make compatibility testing practical. WordPress plugins still declare support ranges like "requires PHP 7.4" or "tested up to PHP 8.3", and checking those claims means running more than one version. Native packages give you the default version quickly, while containers or a virtual machine handle the older ones. The same applies to WooCommerce stores, where you can rehearse refunds, coupons and shipping zones using dummy products instead of real stock.

There is a network argument as well, particularly outside the big cities. Docker images and WordPress tarballs are measured in hundreds of megabytes, and plenty of Australian homes still sit on an NBN plan with a monthly data cap rather than unlimited traffic. Regional users on satellite connections pay far more per gigabyte, so keeping most of the work offline is a genuine saving. Keep a copy of the site on disk, work locally, and upload only when the build is stable.

Finally, a local copy is a good place to use fake data. The Australian Privacy Act 1988 still applies to test data if it contains real customer information, so use placeholder names, throwaway email addresses and invented card numbers for checkout trials. Nothing about the development environment needs to expose anything to the internet.

Getting elementary OS ready for the stack

elementary OS 8 is built on Ubuntu 24.04 LTS, which means the server packages you want are already in the archive. Start by bringing the system up to date in Terminal, the default terminal application on the desktop:

sudo apt update && sudo apt upgrade

It is worth knowing that AppCenter has shifted towards Flatpak applications, so graphical tools such as the browser, code editor and image viewer arrive through there, while anything with a daemon behind it — web servers, databases, PHP — comes from apt. Mixing the two is fine, but remember that Flatpak apps run inside a sandbox with their own idea of file permissions, which matters later when you open your project directory in an editor.

Install the everyday companions while you are in the terminal:

sudo apt install git curl unzip htop build-essential

Then set the clock to where you actually live. Time zone names differ across the country, and it is easy to forget the half-hour offset in Adelaide or the daylight saving shift that begins in Sydney and Melbourne in October:

sudo timedatectl set-timezone Australia/Brisbane

Brisbane keeps standard time all year, Sydney and Melbourne shift forward for the southern summer, and Adelaide runs forty-five minutes ahead of Brisbane during daylight saving. Getting this right now means scheduled posts and transaction timestamps behave sensibly from day one.

One more decision pays off repeatedly: keep project files inside your home directory rather than under /var/www. Flatpak applications, editors and file pickers handle ~/Sites without extra permission prompts, and you avoid the ownership confusion that comes from mixing a www-data service account with your own login.

Comparing the ways to run WordPress locally

There are four broad approaches, and each suits a different kind of work. Installing the LAMP components directly into elementary OS gives the fastest page loads and the least overhead, since there is no virtualisation layer and no image to download. It is also the least isolated, so a badly written script can reach the rest of your system, and it means juggling PHP versions takes extra effort.

Containers solve the isolation problem neatly. You pin an exact PHP version, database release and WordPress release in a text file, and every teammate or every future machine reproduces the same stack precisely. The cost is disk space and that first pull of a base image, which on a capped NBN plan is worth thinking about before you start.

A virtual machine in VirtualBox provides the strongest separation and makes older PHP releases easy, at the price of memory use and a slower boot. For a single small site it feels like overkill, but for testing a migration across operating systems it is hard to beat. Finally, hosted development platforms such as Pantheon handle the server side for you and suit distributed teams, though they reintroduce a monthly bill measured in dollars including GST.

Approach What you install Isolation Typical startup Best for
Native LAMP Apache, MariaDB, PHP via apt Low Seconds Fast day-to-day theme and plugin work
Docker or Podman Container images and a compose file High Under a minute once images are cached Reproducible builds and multiple PHP versions
VirtualBox VM A full guest operating system Very high Around a minute Legacy PHP, migration rehearsals, OS-level testing
Hosted dev platform Nothing locally beyond a client High Always remote Teams that need shared staging and CI

The choice is not permanent. Plenty of people keep a native LAMP setup as their main workspace and add containers only when a project needs a second PHP version, which keeps the daily loop quick while still allowing proper compatibility checks when required.

Installing Apache, MariaDB and PHP

Start by installing the server components and the PHP extensions that WordPress and its plugin ecosystem expect:

sudo apt install apache2 mariadb-server \
  php-cli php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl

Ubuntu 24.04 ships PHP 8.3, which is a sensible default for current work. Enable and start the services so they come up automatically after a reboot, then confirm both are actually running:

sudo systemctl enable --now apache2 mariadb
systemctl status apache2 mariadb --no-pager

Now point Apache at your project directory. Create the folder in your home directory, then add a virtual host configuration in /etc/apache2/sites-available/wordpress-dev.conf:

<VirtualHost *:80>
    ServerName wpdev.test
    DocumentRoot /home/yourname/Sites/wordpress-dev

    <Directory /home/yourname/Sites/wordpress-dev>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/wordpress-dev-error.log
    CustomLog ${APACHE_LOG_DIR}/wordpress-dev-access.log combined
</VirtualHost>

Enable the site and the rewrite module, then reload Apache:

sudo a2ensite wordpress-dev
sudo a2enmod rewrite headers expires
sudo systemctl reload apache2

AllowOverride All matters more than it looks: without it, WordPress cannot write its own .htaccess rules, and pretty permalinks silently fall back to ugly query strings. Give the project folder to your user so Apache can read it and you can write to it.

For the database, create a dedicated user with privileges on a single database rather than reusing the root account. That way a compromised plugin has a narrow blast radius:

sudo mariadb -e "CREATE DATABASE wordpress_dev CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpdev'@'localhost' IDENTIFIED BY 'a-strong-local-password';
GRANT ALL PRIVILEGES ON wordpress_dev.* TO 'wpdev'@'localhost';
FLUSH PRIVILEGES;"

Finally, raise a few PHP limits in /etc/php/8.3/apache2/php.ini. A media-heavy site usually needs memory_limit = 256M, upload_max_filesize = 64M, post_max_size = 64M and max_execution_time = 120, otherwise imports and image uploads fail with unhelpful messages. Reload Apache afterwards so the new values take effect.

Pulling in WordPress with WP-CLI

WP-CLI turns the tedious parts of a fresh install into two commands, and it becomes the primary tool for everything that follows. Fetch the Phar binary and place it in your path:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info

Now download WordPress straight into the folder Apache serves. Move into the project directory first, because WP-CLI works on the current path unless you pass --path explicitly:

cd ~/Sites/wordpress-dev
wp core download
wp config create --dbname=wordpress_dev --dbuser=wpdev \
  --dbpass='a-strong-local-password' --dbhost=localhost --dbprefix=wp_

Generate the configuration file from a template rather than typing it by hand, then install the site with the details you want to see in the dashboard:

wp core install --url='http://wpdev.test' \
  --title='WP Sandbox' --admin_user=admin \
  --admin_password='choose-something-local' \
  --admin_email='dev@example.com' --skip-email
wp option update timezone_string 'Australia/Brisbane'
wp option update date_format 'j F Y'

Give the domain a local address by adding an entry to the hosts file, which maps the name to your own machine:

echo "127.0.0.1 wpdev.test" | sudo tee -a /etc/hosts

Using a .test name avoids the .local suffix, which many home networks reserve for mDNS discovery through Bonjour and can send your browser to the wrong machine. When the install is done, wp plugin install woocommerce --activate, wp theme install astra --activate and wp user create editor editor@example.com --role=editor cover most of the setup you would otherwise click through in the browser.

Tools that make the daily loop smoother

Version control belongs in the local environment from the very beginning, because a sandbox that changes by the hour is hard to reason about. Initialise a repository in the project folder and ignore the files that should never be committed: wp-config.php, the uploads directory, cache folders, .DS_Store and any build artefacts. Commit the theme and plugin code, and keep each feature on its own branch so a half-finished experiment never contaminates the working build.

Email testing needs a catcher rather than a real mailbox. Mailpit listens on port 1025 for outgoing mail and shows everything it receives on a web interface at port 8025, and Mailhog does something similar. Point PHP at it by setting sendmail_path = /usr/local/bin/mailpit in php.ini, then trigger a password reset or a WooCommerce order. Nothing leaves the machine, which means no accidental emails to a client's real customers and no risk of the local server being flagged as a spam source.

For database inspection, Adminer is a single PHP file that gives you the browse, edit and import tools you would expect from a desktop client, and it can run from a second Apache alias or a one-off server such as php -S localhost:8080 -t /usr/share/adminer. Editors also deserve attention on elementary OS, because Flatpak versions of VS Code run sandboxed. Grant access to your home directory once with flatpak override --user --filesystem=home org.code.Code, keep the project under ~/Sites, and the sandbox complaints disappear. A GitHub Desktop or a terminal-based Git client can sit alongside it comfortably.

WP-CLI itself rewards a little configuration. Tab completion for wp commands saves hours of typing, wp eval '...' lets you query or manipulate WordPress options and metadata from the shell, and wp db export produces a compressed .sql.gz snapshot you can restore into a second project with wp db import. wp search replace changes every instance of an old URL when you move a database between environments, which is exactly what you need when cloning a sandbox.

When it breaks: fixes, snapshots and a repeatable rebuild

Almost every problem in a local WordPress environment has a short explanation. "Error establishing a database connection" usually means the MariaDB service is not running, the credentials in wp-config.php do not match the user you created, or the socket path is wrong; check systemctl status mariadb and compare the names carefully. A complaint about a missing MySQL extension means php-mysql was never installed, and adding it with apt fixes it immediately. Permalinks that fall back to ?p=123 point at the AllowOverride setting in your virtual host rather than anything inside WordPress.

When a page returns a blank white screen or a 500 error, read the logs instead of guessing. Apache keeps them in /var/log/apache2/, and sudo journalctl -u apache2 -n 50 shows recent service messages after an update or a configuration change. apache2ctl configtest validates the configuration file and names the exact line with a syntax error, which is quicker than scanning the file by eye. If a service refuses to start after an operating system upgrade, run that same journal command first, since the cause is usually a renamed module or a stale path.

Backups keep the recovery cheap. elementary OS includes Timeshift, which can snapshot the whole system, and it is worth taking a snapshot before you switch PHP versions, install a conflicting package or run a distribution upgrade. WordPress data lives elsewhere, so pair system snapshots with database dumps made through wp db export and keep them in your home directory. The same dump can seed a new project in seconds.

The practical takeaway is to treat the local stack as a project with a written record rather than a pile of commands you half remember. Keep the install steps in a shell script, export the seed data as a compressed SQL file, and store a sanitised copy of the configuration as wp-config-sample.php with the real passwords removed. When you need a clean environment for a new client or a fresh laptop, you restore those three artefacts, start the services and have a working WordPress install in minutes, which is a far better position than rebuilding the same environment from scratch every time.

Browse the News Archive
Latest Updates

From the elementary weekly series

Low-poly faceted abstract render in dark charcoal and electric blue tones, suggesting a news bulletin or announcement
elementary news

elementary weekly #20

The first week with the final Freya release — community reactions, tips, and early impressions gathered in one roundup.

Abstract low-poly geometric scene in midnight blue and soft cyan, conveying a live broadcast or event atmosphere
elementary news

elementary SPECIAL

A live Hangouts event with the elementary OS founders, held on 11 April 2015, discussing the Freya final release.

Low-poly faceted render in deep navy and muted teal with subtle amber highlights, suggesting a tutorial or guide
Tips and Tricks

Timeshift Guide

How to use Timeshift — the intuitive system restore utility for elementary OS — to recover from configuration mishaps.

Explore

Topics & Resources

Dive into guides, application recommendations, and community discussions covering every aspect of elementary OS.