Run update.sh
This commit is contained in:
parent
9d6926337c
commit
04e07fcb51
|
|
@ -45,7 +45,7 @@ For PHP projects run through the command line interface (CLI), you can do the fo
|
|||
### Create a `Dockerfile` in your PHP project
|
||||
|
||||
```dockerfile
|
||||
FROM php:5.6-cli
|
||||
FROM php:7.0-cli
|
||||
COPY . /usr/src/myapp
|
||||
WORKDIR /usr/src/myapp
|
||||
CMD [ "php", "./your-script.php" ]
|
||||
|
|
@ -63,7 +63,7 @@ $ docker run -it --rm --name my-running-app my-php-app
|
|||
For many simple, single file projects, you may find it inconvenient to write a complete `Dockerfile`. In such cases, you can run a PHP script by using the PHP Docker image directly:
|
||||
|
||||
```console
|
||||
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:5.6-cli php your-script.php
|
||||
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php your-script.php
|
||||
```
|
||||
|
||||
## With Apache
|
||||
|
|
@ -73,11 +73,11 @@ More commonly, you will probably want to run PHP in conjunction with Apache http
|
|||
### Create a `Dockerfile` in your PHP project
|
||||
|
||||
```dockerfile
|
||||
FROM php:5.6-apache
|
||||
FROM php:7.0-apache
|
||||
COPY src/ /var/www/html/
|
||||
```
|
||||
|
||||
Where `src/` is the directory containing all your php code. Then, run the commands to build and run the Docker image:
|
||||
Where `src/` is the directory containing all your PHP code. Then, run the commands to build and run the Docker image:
|
||||
|
||||
```console
|
||||
$ docker build -t my-php-app .
|
||||
|
|
@ -87,23 +87,32 @@ $ docker run -d --name my-running-app my-php-app
|
|||
We recommend that you add a custom `php.ini` configuration. `COPY` it into `/usr/local/etc/php` by adding one more line to the Dockerfile above and running the same commands to build and run:
|
||||
|
||||
```dockerfile
|
||||
FROM php:5.6-apache
|
||||
FROM php:7.0-apache
|
||||
COPY config/php.ini /usr/local/etc/php/
|
||||
COPY src/ /var/www/html/
|
||||
```
|
||||
|
||||
Where `src/` is the directory containing all your php code and `config/` contains your `php.ini` file.
|
||||
Where `src/` is the directory containing all your PHP code and `config/` contains your `php.ini` file.
|
||||
|
||||
### How to install more PHP extensions
|
||||
|
||||
We provide the helper scripts `docker-php-ext-configure`, `docker-php-ext-install`, and `docker-php-ext-enable` to more easily install PHP extensions.
|
||||
|
||||
In order to keep the images smaller, PHP's source is kept in a compressed tar file. To facilitate linking of PHP's source with any extension, we also provide the helper script `docker-php-source` to easily extract the tar or delete the extracted source. Note: if you do use `docker-php-source` to extract the source, be sure to delete it in the same layer of the docker image.
|
||||
|
||||
```Dockerfile
|
||||
FROM php:7.0-apache
|
||||
RUN docker-php-source extract \
|
||||
# do important things \
|
||||
&& docker-php-source delete
|
||||
```
|
||||
|
||||
#### 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-fpm
|
||||
FROM php:7.0-fpm
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
|
|
@ -114,14 +123,14 @@ RUN apt-get update && apt-get install -y \
|
|||
&& 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.
|
||||
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. There is no need to run `docker-php-source` manually in this case, since that is handled by the `configure` and `install` scripts.
|
||||
|
||||
#### 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-fpm
|
||||
FROM php:7.0-fpm
|
||||
RUN apt-get update && apt-get install -y libmemcached-dev \
|
||||
&& pecl install memcached \
|
||||
&& docker-php-ext-enable memcached
|
||||
|
|
@ -132,7 +141,7 @@ RUN apt-get update && apt-get install -y libmemcached-dev \
|
|||
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
|
||||
FROM php:7.0-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 \
|
||||
|
|
@ -153,7 +162,7 @@ RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.
|
|||
If you don't want to include a `Dockerfile` in your project, it is sufficient to do the following:
|
||||
|
||||
```console
|
||||
$ docker run -d -p 80:80 --name my-apache-php-app -v "$PWD":/var/www/html php:5.6-apache
|
||||
$ docker run -d -p 80:80 --name my-apache-php-app -v "$PWD":/var/www/html php:7.0-apache
|
||||
```
|
||||
|
||||
# Image Variants
|
||||
|
|
|
|||
Loading…
Reference in New Issue