Giter VIP home page Giter VIP logo

docker-phpfarm's Introduction

phpfarm for docker

This is a build file to create a phpfarm setup. The resulting docker image will run Apache on different ports with different PHP versions accessed via FCGI. The different PHP CLI binaries are accessible as well.

CircleCI

Port PHP Version Binary
8051 5.1.6 php-5.1 (wheezy only)
8052 5.2.17 php-5.2 (wheezy only)
8053 5.3.29 php-5.3
8054 5.4.45 php-5.4
8055 5.5.38 php-5.5
8056 5.6.39 php-5.6
8070 7.0.33 php-7.0
8071 7.1.25 php-7.1
8072 7.2.34 php-7.2
8073 7.3.25 php-7.3 (jessie only)
8074 7.4.13 php-7.3 (jessie only)
8080 8.0.0 php-8.0 (jessie only)
8000 nightly php-x.x (currently unavailable)

There are two tags for this image: wheezy and jessie, referring to the underlying Debian base system releases. Unless you need PHP 5.1 or 5.2 you should always use the jessie tag.

The wheezy image is deprecated and may not run on modern Linux kernels anymore! Booting your host system with vsyscall=emulate kernel parameter may help if you really need it.

The nightly build refers to the current master when the image was built. You probably want to rebuild the image yourself if you need to test against a very recent snapshot. See next section on how to do that.

Building the image

After cloning the git repository, simply run the following command:

docker build -t splitbrain/phpfarm:jessie -f Dockerfile-Jessie .
docker build -t splitbrain/phpfarm:wheezy -f Dockerfile-Wheezy .

This will setup a Debian base system, install phpfarm, download and compile the different PHP versions, extensions and setup Apache. So, yes this will take a while. See the next section for a faster alternative.

On Kernel 4.19 there seems to be a bug. You need to disable the metacopy feature of the overlay filesystem to build the image. echo N > /sys/module/overlay/parameters/metacopy

Downloading the image

Simply downloading the ready made image from Docker Hub is probably the fastest way. Just run one of these:

docker pull splitbrain/phpfarm:jessie
docker pull splitbrain/phpfarm:wheezy

Running the container

The following will run the container and map all ports to their respective ports on the local machine. The current working directory ($PWD) will be used as the document root for the Apache server and the server itself will run with the same user id as your current user ($UID).

docker run --rm -t -i -e APACHE_UID=$UID -v $PWD:/var/www:rw \
  -p 8051:8051 -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 \
  -p 8056:8056 -p 8070:8070 -p 8071:8071 -p 8072:8072 -p 8073:8073 \
  -p 8074:8074 -p 8080:8080 \
  splitbrain/phpfarm:jessie

You can access the Apache/PHP via localhost. Eg. http://localhost:8073 for the PHP 7.3 version. The nightly build is available on port 8000.

Above command will also remove the container again when the process is aborted with CTRL-C (thanks to the --rm option). While running, the Apache and PHP error log is shown on STDOUT.

An alternative is to not isolate the container's network at all from the local machine. This makes it possible for the container to access all the services you're running locally, eg. a database. It will also automatically make all the exposed ports available locally (but you can't remap them, so they need to be available, eg. not used by anything else). To do so use the --network host switch:

docker run --rm -t -i -e APACHE_UID=$UID -v $PWD:/var/www:rw \
   --network host splitbrain/phpfarm:jessie

You can also access the PHP binaries within the container directly. Refer to the table above for the correct names. The following command will run PHP 5.3 on your current working directory.

docker run --rm -t -i -v $PWD:/var/www:rw splitbrain/phpfarm:jessie php-5.3 --version

Alternatively you can also run an interactive shell inside the container with your current working directory mounted.

docker run --rm -t -i -v $PWD:/var/www:rw splitbrain/phpfarm:jessie /bin/bash

Loading custom php.ini settings

All PHP versions are compiled with the config-file-scan-dir pointing to /var/www/.php/. When mounting your own project as a volume to /var/www/ you can easily place custom .ini files in your project's .php/ directory and they should be automatically be picked up by PHP.

XDebug debugging, profiling and tracing

XDebug is enabled in all of the PHP versions. It is preconfigured for immeadiate use.

Profiling and tracing can be triggered through the XDEBUG_PROFILE and XDEBUG_TRACE Post/Get/Ccookie setting - no special trigger value has been set, so any value will trigger. Output files are placed into the volume you mounted to /var/www/ with an xdebug. prefix.

Remote debugging is triggered through the XDEBUG_SESSION cookie. It uses the remote_connect_back setting, so it expects a debugger on port 9000 (the default) on the IP that requested the page.

Of course you can always reconfigure xdebug through a custom ini file as described above.

Using the image for Testing in Gitlab-CI

Gitlab-CI users can use this image to automate testing against different PHP versions. For detailed info refer to the gitlab-ci documentation.

Here's a simple .gitlab-ci.yml example using phpunit.

stages:
  - test

image: splitbrain/phpfarm:jessie

php-5.3:
  stage: test
  script:
    - wget https://phar.phpunit.de/phpunit-old.phar -O phpunit
    - php-5.3 phpunit --coverage-text --colors=never

php-5.4:
  stage: test
  script:
    - wget https://phar.phpunit.de/phpunit-old.phar -O phpunit
    - php-5.4 phpunit --coverage-text --colors=never

php-5.6:
  stage: test
  script:
    - wget https://phar.phpunit.de/phpunit.phar -O phpunit
    - php-5.6 phpunit --coverage-text --colors=never

php-7.0:
  stage: test
  script:
    - wget https://phar.phpunit.de/phpunit.phar -O phpunit
    - php-7.0 phpunit --coverage-text --colors=never

Supported PHP extensions

Here's a list of the extensions available in each of the PHP versions available in the Jessie image. It should cover all the default extensions plus a few popular ones and xdebug for debugging.

Extension PHP 5.3 PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2 PHP 7.3 PHP 7.4 PHP 8.0
bcmath
bz2
calendar
cgi-fcgi
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
pdo
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
phar
posix
reflection
session
simplexml
soap
sockets
spl
sqlite
sqlite3
standard
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib

docker-phpfarm's People

Contributors

eugenesia avatar splitbrain avatar thajeztah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-phpfarm's Issues

museum.php.net is down

I'm willing to try docker-phpfarm, and the system is trying to communicate with museum.php.net to fetch PHP5.2.17... But museum.php.net is down for a while! (see here: bugs.php.net)

Last response : from [email protected] (2014-10-03) : It will be a while. Museum is probably the lowest priority service on this dead box.

Any chance this can be fixed (even by me if I know where to look at 👍)

Error during "docker run"

Hello, I have an error when I use docker run:

In sudo:

docker run --rm -t -i -e APACHE_UID=$UID -v $PWD:/var/www:rw -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 -p 8056:8056 splitbrain/phpfarm
useradd: UID 0 is not unique
chown: invalid user: wwwrun' /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted) chown: invalid user:wwwrun'

With basic user:

docker run --rm -t -i -e APACHE_UID=$UID -v $PWD:/var/www:rw -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 -p 8056:8056 splitbrain/phpfarm
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.6 for ServerName
[Wed Mar 18 19:05:22 2015] [notice] Apache/2.2.22 (Debian) mod_fcgid/2.3.6 configured -- resuming normal operations

Why please ? Thanks.

xdebug in php 7.1

According to the documentation xdebug should be active for php 7.1 but as far as I can tell it just isn't there. Not in phpinfo() or any config files, doesn't connect to the IDE, xdebug_break doesn't exist.

It there a mistake in the documentation or is https://hub.docker.com/r/splitbrain/phpfarm/ out of date or something else?

xdebug?

hi, I've seen you're adding xdebug to the build but somehow it doesn't appear in phpinfo()
PHP Version 5.6.29-0+deb8u1

should I enable it somehow?

thx
regards, dan

xdebug vscode macos debugging not working

Hi, the debugging not working (all php versions). I'm not sure if the problem is in me. I am docker newbie.
I start vs code and listen for debug connection on port 9000, but noting is happening.
Please advise.

virtual hosts

Hi and thank you for your job !

How i can have multiple vhosts, like :
xxx.localhost:8073
xxx.localhost:8072
yyy.localhost:8073
yyy.localhost:8072
etc...
For each website (xxx.localhost) documentRoot can change (like /var/www/xxx/public)

Thank you !

Can't connect to local MySQL server through socket

Hi!
I work on Fedora 25. I ran to the local mysqld server, but the php script cannot access the database from the Docker.

I'm not familiar with Docker, can you help ?

#docker run --rm -t -i -e APACHE_UID=48 -v $PWD:/var/www:rw -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 -p 8056:8056 -p 8070:8070 -p 8071:8071 splitbrain/phpfarm:jessie

AH00112: Warning: DocumentRoot [/var/www/html] does not exist

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message

[Sun Jan 15 14:13:37.545861 2017] [mpm_event:notice] [pid 16:tid 140507995342720] AH00489: Apache/2.4.10 (Debian) mod_fcgid/2.3.9 configured -- resuming normal operations

[Sun Jan 15 14:13:37.545947 2017] [core:notice] [pid 16:tid 140507995342720] AH00094: Command line: '/usr/sbin/apache2'

/var/www/index.php(9) : Warning - mysqli_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

php 8

Hi will you support php 8 ?

PHP DEBUG versions

I noticed that the PHP versions built are DEBUG versions. I was going to use this for a local development image. So I modified it a bit. But how do I make it build RELEASE builds of PHP? I wanted to use Z-Ray with the supported versions but that doesn't work with DEBUG builds.

Integrate with CircleCI

Unable to integrate this project to CircleCI as I don't have admin access to this repo - see screenshot.

circleci_cannot_add_splitbrain_docker_phpfarm

May need to contact CircleCI support for help.

docker-compose example

Hello,

Could you provide an example of docker-compose file to simplify the command to start docker ?

I was thinking a docker-compose (and eventually a .env) for

  • vhosts (project-a.docker, project-b.docker)
  • setup projects in right folder : ./project-a => /var/www/php56/project-a and ./project-b => /var/www/php7.0/project-b

Commands executed as root

I setup my projects with composer and all the files are created as root.
Doesn't matter if I use install, require or create project.
Doesn't matter if I execute command using loaded docker image, or with an independent command.

Is it possible to override that with current user (just like apache's uid)?

php mail

Hi, I am testing php5.2 and can't seem to be able to send mail out thru php app to my mail server where it can easily reach in the network!
I checked dockerfiles..seems like I have to add sendmail or postfix to it and then rebuild it

mysql

How add php-mysql support for image?

include opcache

hi, would it be possible to include opcache in your builds? thanks, dan

do not use default host on port 80

Currently the container starts an Apache on port 80 for the default host. This is not needed and is annoying when you want to use the image with --net=host

Consider adding nginx support

Hi!

First, let me get this out of the way: this is awesome. Thank you for putting it together.

I'm in the middle of setting up a testing environment for the stuff we make at work and on personal projects. We need to quickly be able to test on many different environments from the same codebase. And this, frankly, is an amazing start.

I'm way more than happy to contribute to this project, but want to open some dialogue in terms of support for other pieces to this stack.

First; nginx rather than apache. Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.