├── .docker ├── data │ └── mysql │ │ └── .gitkeep └── images │ ├── nginx │ └── vhost.conf │ ├── php-fpm │ ├── Dockerfile │ ├── php-fpm.conf │ └── php.ini │ └── proxy │ ├── certs │ └── .gitkeep │ ├── html │ └── .gitkeep │ └── vhost.d │ └── .gitkeep ├── .env.dist ├── .gitignore ├── LICENSE ├── README.md ├── app └── web │ └── app.php └── docker-compose.yml /.docker/data/mysql/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devigner/docker-compose-php/0d5f116bf7aec51a20c250deb999d3c8a9185c7e/.docker/data/mysql/.gitkeep -------------------------------------------------------------------------------- /.docker/images/nginx/vhost.conf: -------------------------------------------------------------------------------- 1 | access_log /var/log/nginx/access.log; 2 | error_log /var/log/nginx/error.log; 3 | 4 | server { 5 | listen 0.0.0.0:80; 6 | server_name localhost; 7 | root /var/www/html/web/; 8 | 9 | rewrite ^/app\.php/?(.*)$ /$1 permanent; 10 | try_files $uri @rewriteapp; 11 | location @rewriteapp { 12 | rewrite ^(.*)$ /app.php/$1 last; 13 | } 14 | location ~ ^/(app)\.php(/|$) { 15 | fastcgi_split_path_info ^(.+\.php)(/.*)$; 16 | fastcgi_param HTTPS off; 17 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 18 | include /etc/nginx/fastcgi_params; 19 | 20 | fastcgi_index index.php; 21 | send_timeout 1800; 22 | fastcgi_read_timeout 1800; 23 | fastcgi_pass phpfpm:9000; 24 | } 25 | 26 | location /php/fpm/status { 27 | fastcgi_pass phpfpm:9000; 28 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 29 | include /etc/nginx/fastcgi_params; 30 | } 31 | 32 | location /php/fpm/ping { 33 | fastcgi_pass phpfpm:9000; 34 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 35 | include /etc/nginx/fastcgi_params; 36 | } 37 | } 38 | # 39 | #server { 40 | # listen 443 ssl http2 default_server; 41 | # server_name localhost; 42 | # 43 | # ssl_certificate /etc/nginx/conf.d/server.crt; 44 | # ssl_certificate_key /etc/nginx/conf.d/server.key; 45 | # 46 | # root /var/www/html/web/; 47 | # 48 | # rewrite ^/app\.php/?(.*)$ /$1 permanent; 49 | # try_files $uri @rewriteapp; 50 | # location @rewriteapp { 51 | # rewrite ^(.*)$ /app.php/$1 last; 52 | # } 53 | # location ~ ^/(app)\.php(/|$) { 54 | # fastcgi_split_path_info ^(.+\.php)(/.*)$; 55 | # fastcgi_param HTTPS off; 56 | # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 57 | # include /etc/nginx/fastcgi_params; 58 | # 59 | # fastcgi_index index.php; 60 | # send_timeout 1800; 61 | # fastcgi_read_timeout 1800; 62 | # fastcgi_pass phpfpm:9000; 63 | # } 64 | # 65 | #} 66 | -------------------------------------------------------------------------------- /.docker/images/php-fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7-fpm 2 | # Install modules 3 | RUN apt-get update && apt-get install -y \ 4 | libmcrypt-dev \ 5 | libicu-dev \ 6 | mysql-client \ 7 | && docker-php-ext-install pdo_mysql \ 8 | && docker-php-ext-install iconv \ 9 | && docker-php-ext-install mcrypt \ 10 | && docker-php-ext-install intl \ 11 | && docker-php-ext-install opcache \ 12 | && docker-php-ext-install mbstring 13 | CMD ["php-fpm"] -------------------------------------------------------------------------------- /.docker/images/php-fpm/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ; This file was initially adapated from the output of: (on PHP 5.6) 2 | ; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default 3 | 4 | [global] 5 | 6 | daemonize = no 7 | error_log = /proc/self/fd/2 8 | 9 | [www] 10 | 11 | access.log = /proc/self/fd/2 12 | 13 | 14 | user = www-data 15 | group = www-data 16 | 17 | listen = [::]:9000 18 | 19 | pm = dynamic 20 | pm.max_children = 5 21 | pm.start_servers = 2 22 | pm.min_spare_servers = 1 23 | pm.max_spare_servers = 3 24 | pm.status_path = /php/fpm/status 25 | 26 | clear_env = no 27 | 28 | 29 | ;access.log = /var/log/php-fpm/access.log 30 | access.format = "%t \"%m %r%Q%q\" %s %{mili}dms %{kilo}Mkb %C%%" 31 | catch_workers_output = yes 32 | 33 | php_flag[display_errors] = on 34 | ;php_admin_flag[log_errors] = true 35 | php_admin_value[date.timezone] = "Europe/Amsterdam" 36 | -------------------------------------------------------------------------------- /.docker/images/php-fpm/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | short_open_tag = off 3 | 4 | [Date] 5 | date.timezone = "Europe/Amsterdam" -------------------------------------------------------------------------------- /.docker/images/proxy/certs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devigner/docker-compose-php/0d5f116bf7aec51a20c250deb999d3c8a9185c7e/.docker/images/proxy/certs/.gitkeep -------------------------------------------------------------------------------- /.docker/images/proxy/html/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devigner/docker-compose-php/0d5f116bf7aec51a20c250deb999d3c8a9185c7e/.docker/images/proxy/html/.gitkeep -------------------------------------------------------------------------------- /.docker/images/proxy/vhost.d/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devigner/docker-compose-php/0d5f116bf7aec51a20c250deb999d3c8a9185c7e/.docker/images/proxy/vhost.d/.gitkeep -------------------------------------------------------------------------------- /.env.dist: -------------------------------------------------------------------------------- 1 | VIRTUAL_HOST=example.com 2 | LETSENCRYPT_HOST=example.com 3 | LETSENCRYPT_EMAIL=user@example.com 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | .docker/images/proxy/*/* 4 | !.docker/images/proxy/*/.gitkeep 5 | .env 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Martijn van Beek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-compose-php 2 | 3 | docker-compose setup to run latest PHP 7 under Nginx with every container outputting it's logging 4 | to the docker daemon. 5 | 6 | # Purpose 7 | 8 | Create the ultimate development environment 9 | 10 | # Install 11 | 12 | Install docker and [docker-compose](https://docs.docker.com/compose/install/) 13 | 14 | # Run 15 | 16 | $ git clone https://github.com/devigner/docker-compose-php.git 17 | $ cd docker-compose-php 18 | $ docker-compose build 19 | $ docker-compose up -d 20 | 21 | # Test 22 | 23 | Open url http://localhost and you will see a phpinfo page 24 | 25 | # http/2 26 | 27 | Copy .env.dist to .env and fill in the obvious information 28 | 29 | Open url https://example.com and you will see a phpinfo page running in http/2 30 | -------------------------------------------------------------------------------- /app/web/app.php: -------------------------------------------------------------------------------- 1 |