• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Dockerfile
  • Created about 10 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker with Nginx / PHP-FPM 7.3 7.0 5.6 5.5

Nginx + PHP-FPM docker container

Build Status
GitHub Open Issues GitHub Stars GitHub Forks
Stars on Docker Hub Pulls on Docker Hub

Docker build

Felling like supporting me in my projects use donate button. Thank You!

This is a million12/nginx-php docker container with Nginx + PHP-FPM combo.

For different PHP versions, look up different branches of this repository.
On Docker Hub you can find them under different tags:

  • million12/nginx-php:php74 - PHP 7.4 # built from php74 branch
  • million12/nginx-php:php73 - PHP 7.3 # built from php73 branch
  • million12/nginx-php:php70 - PHP 7.0 # built from php70 branch
  • million12/nginx-php:php56 - PHP 5.6 # built from php56 branch
  • million12/nginx-php:php55 - PHP 5.5 # built from php55 branch

Things included:

- Nginx with HTTP/2 support

This image is based on million12/nginx.
Default vhost is configured and served from /data/www/default. Add .php file to that location to have it executed with PHP.

- PHP-FPM

PHP 7.4 is up & running for default vhost. As soon as .php file is requested, the request will be redirected to PHP upstream. See /etc/nginx/conf.d/php-location.conf.

File /etc/nginx/fastcgi_params has improved configuration to avoid repeating same config options for each vhost. This config works well with most PHP applications (e.g. Symfony2, TYPO3, Wordpress, Drupal).

- PHP basic tuning

Custom PHP.ini directives are inside /etc/php.d.

- Common dev tools for web app development

  • git 2.14.1
  • Ruby 2.3
  • Bundler
  • NodeJS
  • NPM
  • NPM packages like gulp, grunt, bower, browser-sync

Directory structure inside image

/data/www # meant to contain web content
/data/www/default # root directory for the default vhost
/data/logs/ # Nginx, PHP logs
/data/tmp/php/ # PHP temp directories

Error logging

PHP errors are forwarded to stderr (by leaving empty value for INI error_log setting) and captured by supervisor. You can see them easily via docker logs [container]. In addition, they are captured by parent Nginx worker and logged to /data/logs/nginx-error.log'. PHP-FPM logs are available in /data/logs/php-fpm*.log` files.

- pre-defined FastCGI cache for PHP backend

It's not used until specified in location {} context. In your vhost config you can add something like this:

location ~ \.php$ {
    # Your standard directives...
    include               fastcgi_params;
    fastcgi_pass          php-upstream;

    # Use the configured cache (adjust fastcgi_cache_valid to your needs):
    fastcgi_cache         APPCACHE;
    fastcgi_cache_valid   60m;
}

Usage

docker run -d -v /data --name=web-data busybox
docker run -d --volumes-from=web-data -p=80:80 --name=web million12/nginx-php

After that you can see the default vhost content (something like: 'default vhost created on [timestamp]') when you open http://CONTAINER_IP:PORT/ in the browser.

You can replace /data/www/default/index.html with index.php and, for instance, phpinfo() to inspect installed PHP setup. You can do that using separate container which mounts /data volume (docker run -ti --volumes-from=web-data --rm busybox) and adding the file to the above location.

Customise

There are several ways to customise this container, both in a runtime or when building new image on top of it:

  • See million12:nginx for info regarding Nginx customisation, adding new vhosts etc.
  • Override /etc/nginx/fastcgi_params if needed.
  • Add custom PHP *.ini files to /etc/php.d/.
  • Add own PHP-FPM .conf files to /data/conf/php-fpm-www-*.conf to modify PHP-FPM www pool.

ENV variables

NGINX_GENERATE_DEFAULT_VHOST
Default: NGINX_GENERATE_DEFAULT_VHOST=false
Example: NGINX_GENERATE_DEFAULT_VHOST=true
When set to true, dummy default (catch-all) Nginx vhost config file will be generated in /etc/nginx/hosts.d/default.conf. In addition, default index.php file will be created displaying results of phpinfo(). Caveat: this causes security leak because you expose detailed PHP configuration - remember to remove it on production! Use it if you need it, for example to test that your Nginx is working correctly AND/OR if you don't create default vhost config for your app but you still want some dummy catch-all vhost.

STATUS_PAGE_ALLOWED_IP
Default: STATUS_PAGE_ALLOWED_IP=127.0.0.1
Example: STATUS_PAGE_ALLOWED_IP=10.1.1.0/16
Configure ip address that would be allowed to see PHP-FPM status page on /fpm_status URL.

Authors

Author: ryzy ([email protected])
Author: pozgo ([email protected])

More Repositories

1

docker-haproxy

Fully customisable HAProxy load balancer with HTTP/2 and ALPN support. Built on CentOS-7.
Shell
102
star
2

docker-centos-supervisor

Base CentOS-7 with supervisord launcher, highly extensible.
Shell
57
star
3

docker-varnish

Docker container with Varnish 4.x built on top of CentOS-7.
Shell
52
star
4

docker-nginx

Nginx docker image with HTTP/2 support. Extensible, nicely tuned for better performance.
Shell
44
star
5

linodeapi

Deploy CoreOS on Linode.
Shell
36
star
6

docker-mariadb

MariaDB 10 (Tuned ~100Mb size - Alpine)
Shell
29
star
7

docker-zabbix-server

Zabbix Server (Push Notifications, Slack, smtp auth)
Perl
22
star
8

docker-typo3-neos

Docker image with pre-installed Neos CMS.
21
star
9

neos-protobrew-distribution

Neos CMS: PrototypeBrewery.io distribution with Zurb Foundation components.
PHP
19
star
10

docker-zabbix-agent

Zabbix Agent Docker Image (CentOS 7)
Shell
18
star
11

docker-typo3-flow-neos-abstract

Flow and Neos Docker image with extensive customisation.
Shell
15
star
12

M12.Foundation

Neos CMS plugin implementing all Zurb Foundation 5 components.
PHP
14
star
13

docker-php-testing

Container to run PHP tests (unit, functional, behat). Contains selenium server installed.
Shell
10
star
14

Neos.Plugin.SlickCarousel

Slick Carousel for Neos CMS.
PHP
10
star
15

docker-nginx-hhvm

Docker with Nginx+HHVM on CentOS-7
ApacheConf
10
star
16

docker-vsftpd

VSFTP Server in a Docker
Shell
10
star
17

docker-elasticsearch

Docker image with Elasticsearch
Shell
6
star
18

docker-gitbucket

GitBucket Docker Image behind Nginx and with HTTP/2 Support
6
star
19

Flow.Plugin.Rollbar

Rollbar.com integration for Flow and Neos CMS
PHP
6
star
20

docker-ssh

SSH Daemon (CentOS7 & Supervisor)
Shell
6
star
21

docker-gluster

Docker Image of GlusterFS daemon.
Shell
5
star
22

M12.DbExport

Flow/Neos plugin with db:export and db:import commands to export, import the database
PHP
5
star
23

docker-citadel

Citadel Server with WebCit web interface
Shell
5
star
24

docker-jira-service-desk

Jira Service Desk in Docker
Shell
4
star
25

docker-rabbitmq

RabbitMQ CentOS-7 Docker image
Shell
4
star
26

docker-logstash

Logstash server Docker image
Shell
4
star
27

site-m12-io

Open-sourced m12.io website - complete Neos CMS project.
CSS
4
star
28

docker-kibana4

Kibana 4 For Elasticsearch
Shell
3
star
29

docker-mesos-haproxy

Mesos HAProxy Docker Image
Shell
3
star
30

M12.Utils

TYPO3 Neos plugin with misc. M12 libraries / helpers
PHP
3
star
31

docker-php-app-ssh

million12/php-app, extended with running SSHD and easy ssh keys management (via GitHub API)
Shell
3
star
32

docker-sonar

Sonar in docker (CentOS 7)
Shell
3
star
33

docker-neos-react-ui

Neos CMS with its new experimental React UI
Shell
3
star
34

docker-typo3-flow

Docker container with installed TYPO3 Flow default distribution.
3
star
35

docker-jira

Jira Software - Jira with MySQL Support
Shell
2
star
36

ansible-role-docker

Ansible Role: Install Docker (stable)
2
star
37

docker-nexus

Nexus in a docker (CentOS 7)
Shell
2
star
38

docker-logstash-forwarder

Logstash-Forwarder Docker Image
Shell
2
star
39

ansible-role-centos-kubernetes

Ansible Role installing Kubernetes services
2
star
40

docker-aws

Amazon EC2 and Amazon S3 (command-line tool)
Shell
2
star
41

docker-docker

Docker in a Docker
Shell
2
star
42

docker-serverdensity

Docker with sd-agent for ServerDensity monitoring.
Shell
1
star
43

ansible-role-docker-experimental

Ansible Role: Install Docker (experimental)
1
star
44

docker-confluence

Atlassian Confluence in a Docker
Shell
1
star
45

ansible-role-centos-update

Ansible Role: Updating CentOS to latest, adds epel-repo and basic system tools
1
star
46

Pb.Site

Neos site package for M12.Foundation plugin.
JavaScript
1
star
47

docker-toolbox

CoreOS toolbox replacement, based on CentOS-7, with few extra admin tools
1
star
48

Neos.NodeType.CodeSnippet

Very basic CodeSnippet node element for Neos CMS
HTML
1
star
49

Flow.Plugin.SegmentCom

Segment tracking service wrapper to use in Flow/Neos projects
PHP
1
star
50

docker-nginx-node

Nginx with NodeJS
Dockerfile
1
star
51

docker-hippocms

Docker image with demo of Hippo CMS 7.9, an open source Java CMS
1
star
52

docker-rackspace-cloud-backup

Dockerized Rackspace backup agent, driveclient.
Shell
1
star