• Stars
    star
    183
  • Rank 205,850 (Top 5 %)
  • Language
    Dockerfile
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 5 years ago

Reviews

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

Repository Details

Apache + PHP container image which can be linked to other containers.

Table of Contents

Installation

docker pull romeoz/docker-apache-php

or other versions (7.3, 7.2, 7.1, 7.0, 5.6, 5.5, 5.4 or 5.3):

docker pull romeoz/docker-apache-php:7.1

Alternately you can build the image yourself.

git clone https://github.com/romeoz/docker-apache-php.git
cd docker-apache-php
docker build -t="$USER/docker-apache-php" .

Quick Start

Run the application container:

docker run --name app -d -p 8080:80 romeoz/docker-apache-php

The simplest way to login to the app container is to use the docker exec command to attach a new process to the running container.

docker exec -it app bash

Development/Persistence

For development a volume should be mounted at /var/www/app/.

The updated run command looks like this.

docker run --name app -d -p 8080:80 \
  -v /host/to/path/app:/var/www/app/ \
  romeoz/docker-apache-php

This will make the development.

Linked to other container

As an example, will link with RDBMS PostgreSQL.

docker network create pg_net

docker run --name db -d romeoz/docker-postgresql

Run the application container:

docker run --name app -d -p 8080:80 \
  --net pg_net \
  -v /host/to/path/app:/var/www/app/ \
  romeoz/docker-apache-php

Adding PHP-extension

You can use one of two choices to install the required php-extensions:

  1. docker exec -it app bash -c 'apt-get update && apt-get install php-mongo && rm -rf /var/lib/apt/lists/*'

  2. Create your container on based the current. Сontents Dockerfile:

FROM romeoz/docker-apache-php:5.6

RUN apt-get update \
    && apt-get install -y php-mongo \
    && rm -rf /var/lib/apt/lists/* 

WORKDIR /var/www/app/

EXPOSE 80 443

CMD ["/sbin/entrypoint.sh"]

Next step,

docker build -t php-5.6 .
docker run --name app -d -p 8080:80 php-5.6

See installed php-extension: docker exec -it app php -m

PHP-extension "Mcrypt" was REMOVED in PHP 7.2. Use Sodium or OpenSSL

Logging

All the logs are forwarded to stdout and sterr. You have use the command docker logs.

docker logs app

####Split the logs

You can then simply split the stdout & stderr of the container by piping the separate streams and send them to files:

docker logs app > stdout.log 2>stderr.log
cat stdout.log
cat stderr.log

or split stdout and error to host stdout:

docker logs app > -
docker logs app 2> -

####Rotate logs

Create the file /etc/logrotate.d/docker-containers with the following text inside:

/var/lib/docker/containers/*/*.log {
    rotate 31
    daily
    nocompress
    missingok
    notifempty
    copytruncate
}

Optionally, you can replace nocompress to compress and change the number of days.

Out of the box

  • Ubuntu 12.04, 14.04, 16.04 or 18.04 LTS
  • Apache 2.4.x/2.2.x
  • PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 or 7.3
  • Composer (package manager)

Environment depends on the version of PHP.

License

Apache + PHP docker image is open-sourced software licensed under the MIT license

More Repositories

1

docker-nginx-php

Nginx + PHP-FPM container image which can be linked to other containers.
Dockerfile
108
star
2

rock-sanitize

Flexible sanitizator for PHP.
PHP
47
star
3

docker-sphinxsearch

Sphinx Search container image which can be linked to other containers.
Shell
29
star
4

rock-validate

Flexible validator for PHP with I18N.
PHP
25
star
5

docker-postgresql

PostgreSQL container image which can be linked to other containers.
Shell
22
star
6

docker-mysql

MySQL container image which can be linked to other containers.
Shell
19
star
7

docker-phpfpm

PHP-FPM container image which can be linked to other containers.
Dockerfile
16
star
8

docker-redis

Redis container image which can be linked to other containers.
Shell
9
star
9

rock

The Rock PHP framework.
PHP
6
star
10

docker-mongodb

MongoDB container image which can be linked to other containers.
Shell
6
star
11

rock-cache

Unified API for key-value storages in memory. As a storage can be used: APC, Redis, Memcached, Couchbase or MongoDB.
PHP
6
star
12

rock-db

Object Relational Mapping (ORM) for PHP
PHP
5
star
13

rock-template

Flexible template engine for PHP with MODx-like syntax.
PHP
3
star
14

rock-i18n

i18n library for PHP
PHP
2
star
15

docker-nginx

Nginx container image which can be linked to other containers.
Dockerfile
2
star
16

rock-mq

Unified API for message queue services
PHP
2
star
17

docker-memcached

Memcached container image which can be linked to other containers.
Shell
2
star
18

rock-security

Security module for Rock Framework
PHP
1
star
19

docker-rock-validate

Demo for "Rock validate"
PHP
1
star
20

rock-sphinx

Object Relational Mapping (ORM) for Sphinx Search
PHP
1
star
21

docker-rock-sanitize

Demo for "Rock sanitize"
PHP
1
star
22

rock-morphy

[READ ONLY] Morphy module for Rock Framework
PHP
1
star
23

rock-mongodb

Object Document Mapper (ODM) for MongoDB
PHP
1
star
24

rock-route

Simple router for PHP
PHP
1
star
25

rock-helpers

Helpers for Rock Framework.
PHP
1
star