Skip to content

PHP + Apache locally

cloud-apache-container (image: cac) is the same Apache + PHP image we use for hosted PHP sites. It’s based on AlmaLinux 9, ships with PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, and 8.5 side-by-side (default 8.3), and uses Apache with mod_ssl.

Pre-built tags are pushed on every change:

  • cac:latest — the default (PHP 8.3).
  • cac:php74, cac:php80, cac:php81, cac:php82, cac:php83, cac:php84, cac:php85 — pin to a specific PHP version.

Pull from repo.anhonesthost.net/cloud-hosting-platform/cac:<tag>.

The repo ships a local-dev.sh script that handles the Docker incantation, creates the volume + log directories, generates helper scripts, and installs a fresh WordPress in the web root.

  1. Clone the repo and cd in:

    Terminal window
    git clone https://repo.anhonesthost.net/cloud-hosting-platform/cloud-apache-container.git
    cd cloud-apache-container
  2. Start a local instance:

    Terminal window
    ./local-dev.sh -n local-dev
  3. The script will:

    • Create a user directory and log folders (apache/, system/).
    • Create a Docker volume for MySQL.
    • Start the container with the right env vars.
    • Generate helper scripts in your root path (instance_start, instance_stop, instance_logs, instance_db_info).
    • Install WordPress in your web root.
    • Print the MySQL credentials it generated.
  4. Open http://localhost/ in a browser — WordPress’s setup screen should be there.

FlagPurposeDefault
-nContainer name (required)
-pHTTP port80
-sHTTPS port443
-rRoot path for files and DBcurrent directory
-aPHP version (74, 80, 81, 82, 83, 84, 85)83
-vVerbose modeoff
-hShow help

Example — run a PHP 8.5 instance on port 8080:

Terminal window
./local-dev.sh -n my-php85-site -a 85 -p 8080 -s 8443

If you’d rather skip the script and run it yourself:

Terminal window
mkdir -p local-development/domain.tld
cd local-development/domain.tld
mkdir user
mkdir -p user/logs/{apache,system}
docker run -d -it \
-p 80:80 -p 443:443 \
-e PHPVER=84 -e environment=DEV \
--mount type=bind,source="$(pwd)"/user,target=/home/myuser \
-v"$name-mysql":/var/lib/mysql \
-e uid=30001 -e user=myuser -e domain=localhost \
--name local-dev \
repo.anhonesthost.net/cloud-hosting-platform/cac:latest
Terminal window
docker exec -it local-dev /bin/bash

Useful for running wp-cli, tailing logs from inside, or checking PHP modules.

Inside the containerOn your laptop (via bind mount)
/home/myuser/public_html/ — Apache docrootlocal-development/domain.tld/user/public_html/
/home/myuser/logs/apache/ — Apache logslocal-development/domain.tld/user/logs/apache/
/var/lib/mysql/ — MySQL dataNamed Docker volume (<name>-mysql)
/home/myuser/mysql_credsSame path on the bind mount

local-dev.sh installs WordPress automatically. If you started manually:

Terminal window
docker exec -it local-dev bash
cat /home/myuser/mysql_creds # see the credentials
cd /home/myuser/public_html
wp core download
wp config create --dbname=... --dbuser=... --dbpass=... --dbhost=localhost
wp core install --url=http://localhost --title="Local Dev" --admin_user=admin [email protected]

The helper scripts the local-dev script writes are the easy path:

Terminal window
./instance_stop # stop the container
./instance_start # start it again
./instance_logs # tail Apache logs
./instance_db_info # show MySQL credentials

To wipe everything:

Terminal window
docker rm -f local-dev
docker volume rm local-dev-mysql
rm -rf local-development/

cloud-apache-container on Gitea — Dockerfile, entrypoint, build configs, and the local-dev.sh script.

Still stuck? Open a support ticket and our team will help.