Implements PHP-FPM 8.3 & Nginx 1.24 container image built on Alpine Linux, with PDO support enabled.
Repository: [https://github.com/doritoes/docker-php-nginx-app-server]
- Built on the lightweight and secure Alpine Linux distribution
- Forked fom best practice repository [https://github.com/TrafeX/docker-php-nginx]
The entire purpose of this repository is to enable PDO support.
NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php83/modules/pdo_mysql (Error loading shared library /usr/lib/php83/modules/pdo_mysql: No such file or directory), /usr/lib/php83/modules/pdo_mysql.so (Error relocating /usr/lib/php83/modules/pdo_mysql.so: pdo_throw_exception: symbol not found)) in Unknown on line 0
It is uncertain if this is an error trying to relocate the PDO driver, or if the PDO driver will fail. This need to be tested.
The goal of this container image is to provide an a LAMP application server for use with PDO and an external MySQL service under Kubernetes.
Start the Docker container:
docker run -p 80:8080 doritoes/php-nginx-app-server
See the PHP info on http://localhost, or the static html page on http://localhost/test.html
Or mount your own code to be served by PHP-FPM & Nginx
docker run -p 80:8080 -v ~/my-codebase:/var/www/html doritoes/php-nginx
In config/ you'll find the default configuration files for Nginx, PHP and PHP-FPM. If you want to extend or customize that you can do so by mounting a configuration file in the correct folder;
Nginx configuration:
docker run -v "`pwd`/nginx-server.conf:/etc/nginx/conf.d/server.conf" doritoes/php-nginx-app-server
PHP configuration:
docker run -v "`pwd`/php-setting.ini:/etc/php83/conf.d/settings.ini" doritoes/php-nginx-app-server
PHP-FPM configuration:
docker run -v "`pwd`/php-fpm-settings.conf:/etc/php83/php-fpm.d/server.conf" doritoes/php-nginx-app-server
Note; Because -v
requires an absolute path I've added pwd
in the example to return the absolute path to the current directory
To modify this container to your specific needs please see the following examples;