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.
Image tags
Section titled “Image tags”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>.
Quick start with local-dev.sh
Section titled “Quick start with local-dev.sh”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.
-
Clone the repo and
cdin:Terminal window git clone https://repo.anhonesthost.net/cloud-hosting-platform/cloud-apache-container.gitcd cloud-apache-container -
Start a local instance:
Terminal window ./local-dev.sh -n local-dev -
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.
- Create a user directory and log folders (
-
Open
http://localhost/in a browser — WordPress’s setup screen should be there.
| Flag | Purpose | Default |
|---|---|---|
-n | Container name (required) | — |
-p | HTTP port | 80 |
-s | HTTPS port | 443 |
-r | Root path for files and DB | current directory |
-a | PHP version (74, 80, 81, 82, 83, 84, 85) | 83 |
-v | Verbose mode | off |
-h | Show help | — |
Example — run a PHP 8.5 instance on port 8080:
./local-dev.sh -n my-php85-site -a 85 -p 8080 -s 8443Manual Docker usage
Section titled “Manual Docker usage”If you’d rather skip the script and run it yourself:
mkdir -p local-development/domain.tldcd local-development/domain.tldmkdir usermkdir -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:latestGet a shell inside the container
Section titled “Get a shell inside the container”docker exec -it local-dev /bin/bashUseful for running wp-cli, tailing logs from inside, or checking PHP modules.
Where things live
Section titled “Where things live”| Inside the container | On your laptop (via bind mount) |
|---|---|
/home/myuser/public_html/ — Apache docroot | local-development/domain.tld/user/public_html/ |
/home/myuser/logs/apache/ — Apache logs | local-development/domain.tld/user/logs/apache/ |
/var/lib/mysql/ — MySQL data | Named Docker volume (<name>-mysql) |
/home/myuser/mysql_creds | Same path on the bind mount |
WordPress
Section titled “WordPress”local-dev.sh installs WordPress automatically. If you started manually:
docker exec -it local-dev bashcat /home/myuser/mysql_creds # see the credentialscd /home/myuser/public_htmlwp core downloadwp config create --dbname=... --dbuser=... --dbpass=... --dbhost=localhostStop / start / clean up
Section titled “Stop / start / clean up”The helper scripts the local-dev script writes are the easy path:
./instance_stop # stop the container./instance_start # start it again./instance_logs # tail Apache logs./instance_db_info # show MySQL credentialsTo wipe everything:
docker rm -f local-devdocker volume rm local-dev-mysqlrm -rf local-development/Source
Section titled “Source”cloud-apache-container on Gitea — Dockerfile, entrypoint, build configs, and the local-dev.sh script.
Related
Section titled “Related”- Node + Nginx locally
- Create a site — the hosted side.
Still stuck?
Section titled “Still stuck?”Still stuck? Open a support ticket and our team will help.