Steps to make Nginx+PHP images using Docker

  • 2020-05-17 07:04:25
  • OfStack

preface

This article is to introduce the use of Docker nginx+php mirror, mirror in this article is centos + nginx 1.9.7 + php 5.6.14, the following words do not say, directly look at the implementation of the steps.

1. First download to nginx and php:

nginx - 1.9.5. tar. gz download: http: / / nginx org/en/download html

php - 5.6.14. tar. gz download: > http: / / php net/downloads php

2. And the extension package so:

memcache-2.2.4.tgz

The redis php so package download: > https: / / github com/nicolasff phpredis/zipball/master

3. First install the third source of yum:


wget http://www.atomicorp.com/installers/atomic
sh ./atomic

Installation steps

Step 1 is based on docker centos mirroring

Step 2, yum installs 1 of the required packages:


yum install -y openssh-clients
yum install -y gcc gcc-c++ kernel-devel
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum install -y php-mcrypt libmcrypt libmcrypt-devel
yum install -y libxml2 libxml2-devel
yum install -y bzip2 bzip2-devel
yum install -y curl-devel
yum install -y libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64
yum install -y libjpeg-turbo libjpeg-turbo-devel libjpeg-turbo-static libjpeg-turbo-utils
yum install -y libc-client.x86_64
yum install -y uw-imap-devel
yum install -y libxslt-devel
yum install -y zip unzip autoconf

Step 3, install nginx:


./configure --with-http_ssl_module

After installing nginx, the installation directory is: /usr/local/nginx

To see which modules nginx installs you can use the command:


/usr/local/nginx/sbin/nginx -V

Step 4, install php:


./configure --prefix=/usr/local/php --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr/local/libxml --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --enable-gd-native-ttf --with-openssl --with-fpm-user=www --with-fpm-group=www --with-libdir=lib64 --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-xml --enable-shmop --enable-session --enable-ctype --with-iconv-dir --with-iconv

After installing php, the installation directory is: /usr/local/php

Step 5, install memcache's php extension:

Download address: > https: / / pecl php. net/package/memcache


tar -zvxf memcache-2.2.4.tgz
cd memcache-2.2.4
/usr/local/php/bin/phpize
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
make && make install

Step 6, install redis's php extension:


wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip
unzip php-redis.zip
cd php-redis
/usr/local/php/bin/phpize
./configure --enable-redis --with-php-config=/usr/local/php/bin/php-config
make && make install

Step 7, install mongodb's php extension:

Download address: > https: / / pecl php. net/package/mongo


wget https://pecl.php.net/get/mongo-1.6.11.tgz
tar -zvxf mongo-1.6.11.tgz
cd mongo-1.6.11
/usr/local/php/bin/phpize
./configure --enable-mongo--with-php-config=/usr/local/php/bin/php-config
make && make install

Step 8. php adds memcache, redis, mongodb extended support:

Open/usr/local/php/etc/php ini, add extensions:


extension = redis.so
extension = memcache.so
extension = mongo.so

To complete.

The attached:

To reduce the size of the image package, after installation, use the command to clear the installation package:


make clean
yum clean all

More php extensions can be downloaded here:

>https://pecl.php.net/packages.php

Start the php-fpm command:


yum install -y openssh-clients
yum install -y gcc gcc-c++ kernel-devel
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum install -y php-mcrypt libmcrypt libmcrypt-devel
yum install -y libxml2 libxml2-devel
yum install -y bzip2 bzip2-devel
yum install -y curl-devel
yum install -y libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64
yum install -y libjpeg-turbo libjpeg-turbo-devel libjpeg-turbo-static libjpeg-turbo-utils
yum install -y libc-client.x86_64
yum install -y uw-imap-devel
yum install -y libxslt-devel
yum install -y zip unzip autoconf
0

Start the nginx command:


yum install -y openssh-clients
yum install -y gcc gcc-c++ kernel-devel
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum install -y php-mcrypt libmcrypt libmcrypt-devel
yum install -y libxml2 libxml2-devel
yum install -y bzip2 bzip2-devel
yum install -y curl-devel
yum install -y libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64
yum install -y libjpeg-turbo libjpeg-turbo-devel libjpeg-turbo-static libjpeg-turbo-utils
yum install -y libc-client.x86_64
yum install -y uw-imap-devel
yum install -y libxslt-devel
yum install -y zip unzip autoconf
1

The docker startup command is:


yum install -y openssh-clients
yum install -y gcc gcc-c++ kernel-devel
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum install -y php-mcrypt libmcrypt libmcrypt-devel
yum install -y libxml2 libxml2-devel
yum install -y bzip2 bzip2-devel
yum install -y curl-devel
yum install -y libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64
yum install -y libjpeg-turbo libjpeg-turbo-devel libjpeg-turbo-static libjpeg-turbo-utils
yum install -y libc-client.x86_64
yum install -y uw-imap-devel
yum install -y libxslt-devel
yum install -y zip unzip autoconf
2

conclusion

The above are all the steps of making Nginx+PHP mirror with Docker. I hope the content of this paper can bring a definite reference value to your study or work. If you have any questions, you can leave a message to communicate.


Related articles: