Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openbridge/ob_php-fpm
PHP-FPM container for NGINX using Alpine, Opcache, Dynamic Resources, Monitoring, Security
https://github.com/openbridge/ob_php-fpm
alpine docker nginx nginx-php-fpm opcache php-fpm php8 redis-cache symfony wordpress
Last synced: 6 days ago
JSON representation
PHP-FPM container for NGINX using Alpine, Opcache, Dynamic Resources, Monitoring, Security
- Host: GitHub
- URL: https://github.com/openbridge/ob_php-fpm
- Owner: openbridge
- License: mit
- Created: 2016-01-31T23:38:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-10T17:30:31.000Z (23 days ago)
- Last Synced: 2025-01-20T17:13:14.250Z (13 days ago)
- Topics: alpine, docker, nginx, nginx-php-fpm, opcache, php-fpm, php8, redis-cache, symfony, wordpress
- Language: Shell
- Homepage: https://www.openbridge.com
- Size: 751 KB
- Stars: 96
- Watchers: 13
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP-FPM Tubocharged
Not your average PHP-FPM serviceβthis is a highly optimized, lightning-fast β‘ PHP processing engine designed to supercharge your PHP applications like Wordpress. This PHP-FPM service takes the standard implementation and **amps it up** to deliver unparalleled performance.## Fuels The Wordpress Accelerated Stack πβ‘π¦π
- π₯ **Blazing Speed**: Optimized for ultra-fast execution of PHP scripts.
- π οΈ **Advanced Configuration**: Tuned for modern, high-traffic workloads.
- π¦ **Docker-Ready**: Fully containerized for quick and easy deployment.
- π **Performance Monitoring**: Built-in metrics for real-time insights.
- βοΈ **Customizability**: Easily tweak configurations to fit your specific needs.
- 𧩠**Compatible**: Works seamlessly with existing PHP applications.## Features π‘
1. **Enhanced Process Management** π§βπ»
- Dynamically adjusts PHP resources based on your host for maximum efficiency.2. **Optimized Docker Setup** π³
- Custom-built Docker image with a minimal footprint for reduced overhead.3. **High Concurrency** π
- Supports numerous simultaneous connections with minimal latency.4. **Comprehensive Tuning** π―
- Fine-tuned configurations to handle anything from small sites to enterprise-scale applications.5. **Opcache Optimization** ποΈ
- Preloads frequently used scripts into memory for instant execution.
- Automatically adjusts Opcache memory consumption based on the available RAM in the container.
- Prevents downtime by keeping compiled scripts in memory between requests.6. **Redis Integration** π΄
- Simplifies session storage by offloading it to Redis.
- Enables persistent object caching for high-speed data retrieval.
- Fully customizable through environment variables to connect to external or local Redis servers.7. **Nginx Integration** π
- Nginx as a reverse proxy to PHP-FPM, handling SSL termination, caching, and static file delivery.
- Configured to work with Brotli and Gzip compression for smaller page sizes and faster load times.
- Supports dynamic FastCGI caching to offload repeated requests.8. **Wordpress CLI** π―
- Wordpress CLI is pre-installed ready to automate configuration and operations.## Getting Started π
### Prerequisites π
- Docker installed on your machine π³
- Basic knowledge of PHP and containerized applications## Build
```
docker build -t openbridge/php-fpm .
```Or pull it:
```
docker pull openbridge/php-fpm
```## Setting Your `APP_DOCROOT`
The default root app directory is `/usr/share/nginx/html`. If you want to change this default you need to see `APP_DOCROOT` via ENV variable. For example, if you want to use `/html` as your root you would set `APP_DOCROOT=/html`
IMPORTANT: The `APP_DOCROOT` should be the same directory that you use within NGINX for the `NGINX_DOCROOT` which is `/usr/share/nginx/html`. Incorrectly setting the root for your web and applciation files is usually is the basis for most config errors, especially using applications like Wordpress.
## Dynamic Resource Allocation
The PHP and cache settings are a function of the available system resources. This allocation factors in available memory and CPU which is assigned proportionately. The proportion of resources was defined according to researched best practices and reading PHP docs.## Permissions
We have standardized on the user, group and UID/GID to work seamlessly with NGINX```docker
&& addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -h /var/cache/php-fpm -s /sbin/nologin -G www-data www-data \
```
We are also make sure all the underlying permissions and owners are set correctly based on the doc root like `/usr/share/nginx/html`:## Logging
Logs are sent to stdout and stderr PHP-FPM.
You will likely want to dispatch these logs to a service like Amazon Cloudwatch. This will allow you to setup alerts and triggers to perform tasks based on container activity.## Issues
If you have any problems with or questions about this image, please contact us through a GitHub issue.
## Contributing
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
## References
PHP
* https://www.kinamo.be/en/support/faq/determining-the-correct-number-of-child-processes-for-php-fpm-on-nginx
* https://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/
* https://www.tecklyfe.com/adjusting-child-processes-php-fpm-nginx-fix-server-reached-pm-max_children-setting/
* https://serversforhackers.com/video/php-fpm-process-management
* https://devcenter.heroku.com/articles/php-concurrencyThe image is based on the official PHP docker image:
* https://github.com/docker-library/php## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details