A production-ready Dockerfile for PHP 8.1 tailored specifically for WordPress or other PHP-based systems. This image includes a wide range of essential PHP extensions and tools like SourceGuardian and ionCube, widely used in the WordPress ecosystem.
- PHP Version: 8.1 (FPM Alpine)
- Extensions:
- Core PHP extensions:
bcmath,bz2,calendar,curl,exif,fileinfo,ftp,gd,gettext,imagick,imap,intl,ldap,mbstring,mcrypt,memcached,mongodb,mysqli,opcache,pdo,pdo_mysql,redis,soap,sodium,sysvsem,sysvshm,xmlrpc,xsl,zip - Advanced debugging tools:
xdebug - Profiling support:
xhprof
- Core PHP extensions:
- PHP Encryption Support:
- ionCube Loader
- SourceGuardian
- Additional Tools:
- Optimizations:
- OPCache configuration for performance
- Base OS: Alpine Linux (lightweight and secure)
- Docker installed on your system.
Pull the pre-built image from Docker Hub (replace your-dockerhub-repo with your repository, if published):
# Pull the image
docker pull basemax/docker-php8.1Run the container:
docker run -d \
-v $(pwd):/var/www/html \
-p 9000:9000 \
--name php-fpm-basemax \
basemax/docker-php8.1Here’s an example docker-compose.yml file for use with this Docker image and Nginx:
services:
php:
image: basemax/docker-php8.1
volumes:
- .:/var/www/html
ports:
- "9000:9000"
nginx:
image: nginx:alpine
volumes:
- .:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
depends_on:
- phpStart the services:
docker-compose up -dThe Dockerfile includes optimized OPCache settings. If you need to modify them, edit the configuration file located in /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini.
Composer is pre-installed and available globally.
composer --versionWP-CLI is pre-installed for managing WordPress installations.
wp --infoThese popular encryption tools are included and pre-configured.
Use the Docker Compose example above and adjust paths as needed.
Download WordPress to your project directory:
curl -O https://wordpress.org/latest.tar.gzRun the containers:
docker-compose up -dAccess your WordPress site at http://localhost:8080.
Use the install-php-extensions script to install additional extensions:
RUN install-php-extensions <extension-name>By default, the www-data user and group IDs are set to 1000 for compatibility with host systems. Adjust as needed:
usermod -u <UID> www-data
groupmod -g <GID> www-dataContributions are welcome! Please fork the repository and submit a pull request.
This image is provided as-is without warranty. Please test thoroughly before using in production environments.
This project is licensed under the MIT License.