Dockerfile:
FROM centos:centos7
RUN curl 'https://setup.ius.io/' -o setup-ius.sh \
&& bash setup-ius.sh \
&& rm -f setup-ius.sh \
&& yum -y update \
&& yum -y install \
php71u-common \
php71u-cli \
php71u-fpm \
php71u-opcache \
php71u-xml \
php71u-json \
php71u-pdo \
php71u-mysqlnd \
php71u-intl \
php71u-mbstring \
php71u-mcrypt \
php71u-gd \
php71u-soap \
php71u-process \
php71u-pecl-redis \
php71u-pecl-xdebug \
php71u-fpm-httpd
EXPOSE 9000
CMD ["php-fpm", "-F"]
Build the docker image:
# docker build -t junhsieh/php7.1-fpm:0.0.0 .
Some important settings to be changed:
# vim /etc/php-fpm.d/www.conf
; Change ownership:
user = php-fpm
group = php-fpm
; Note: Ubuntu uses www-data user. Add php-fpm user to www-data group if the other container used it.
; # groupadd -g 33 www-data
; # useradd www-data -m -c 'web user' -u 33 -g 33
; # usermod -a -G www-data php-fpm
; # id php-fpm
; Now, restart this container to ensure php-fpm user is in www-data group.
; Bind port 9000 to the all interfaces:
listen = 9000
;listen = [::]:9000
; Note: PHP-FPM has a listen.client_allowed setting which allows you to set a list of IPs that can connect, or leave blank for any IP to connect. However, even with it being left blank, the issue still persisted. Digging into the official PHP-FPM repo, I discovered that you also need to set listen = [::]:9000 which then began to allow any IP to connect.
; Note: https://stackoverflow.com/questions/19806945/docker-and-connections-between-containers
; Comment out the following line:
;listen.allowed_clients = 127.0.0.1
; Note: "listen.allowed_clients = any" will not work.
; Note: "listen.allowed_clients = other-container-name" will not work. IP address only.
; Uncomment the following line to debug the issue:
catch_workers_output = yes
; Note: Comment it out on production.
xdebug setting:
### xdebug setting
###
; Enable xdebug extension module
zend_extension=xdebug.so
;zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9009
; Note: php-fpm uses port 9000 as well.
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_mode=req
xdebug.max_nesting_level=1000
Reference:
https://developers.redhat.com/blog/2014/12/29/running-php-fpm-in-docker/
No comments:
Post a Comment