From e216e2f5465fd617f363d09ad0252ca2d3c3a0dd Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 18 Jan 2016 16:44:50 -0800 Subject: [PATCH] Fix whitespace and update examples and organization --- php/content.md | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/php/content.md b/php/content.md index 1cc047a74..b7146e681 100644 --- a/php/content.md +++ b/php/content.md @@ -66,34 +66,56 @@ Where `src/` is the directory containing all your php code and `config/` contain ### How to install more PHP extensions -We provide two convenient scripts named `docker-php-ext-configure` and `docker-php-ext-install`, you can use them to easily install PHP extension. +We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-install`, and `docker-php-ext-enable` to more easily install PHP extensions. + +#### PHP Core Extensions For example, if you want to have a PHP-FPM image with `iconv`, `mcrypt` and `gd` extensions, you can inherit the base image that you like, and write your own `Dockerfile` like this: ```dockerfile -FROM php:5.6-fpm -# Install modules +FROM php:5-fpm RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng12-dev \ - && docker-php-ext-install iconv mcrypt \ + && docker-php-ext-install -j$(nproc) iconv mcrypt \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ - && docker-php-ext-install gd -CMD ["php-fpm"] + && docker-php-ext-install -j$(nproc) gd ``` Remember, you must install dependencies for your extensions manually. If an extension needs custom `configure` arguments, you can use the `docker-php-ext-configure` script like this example. -### How to install PECL extensions -Some "extension" are in reality [PECL](https://pecl.php.net/) extension. To install a pecl extension you need to do this (for memcached) : +#### PECL extensions + +Some extensions are not provided with the PHP source, but are instead available through [PECL](https://pecl.php.net/). To install a PECL extension, use `pecl install` to download and compile it, then use `docker-php-ext-enable` to enable it: ```dockerfile -FROM php:5.6-fpm -# Install pecl extension -RUN apt-get update && apt-get install -y libmemcached-dev && pecl install memcached -CMD ["php-fpm"] +FROM php:5-fpm +RUN apt-get update && apt-get install -y libmemcached-dev \ + && pecl install memcached \ + && docker-php-ext-enable memcached +``` + +#### Other extensions + +Some extensions are not provided via either Core or PECL; these can be installed too, although the process is less automated: + +```dockerfile +FROM php:5-apache +RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \ + && mkdir -p xcache \ + && tar -xf xcache.tar.gz -C xcache --strip-components=1 \ + && rm xcache.tar.gz \ + && ( \ + cd xcache \ + && phpize \ + && ./configure --enable-xcache \ + && make -j$(nproc) \ + && make install \ + ) \ + && rm -r xcache \ + && docker-php-ext-enable xcache ``` ### Without a `Dockerfile`