简体   繁体   中英

how to change the loaded configuration file PHP from CLI to FPM

After installed Apache/PHP into MPM Event engine for PHP 7.3 FPM :

  • I realize that PHP-FPM is installed
  • I confirm that PHP-FPM status is activate by service php7.3-fpm status
  • My /etc/php/ directory contains the cli and fpm directory
  • My Apache conf enabled directory contains symlink for php7.3-fpm.conf

But when I exec php -i | grep 'Configuration' php -i | grep 'Configuration' I can read that php read configuration

into /etc/php/cli/php.ini

but not /etc/php/fpm/php.ini

How can I switch config file loaded by PHP ?

This is my install script dockerfile :

FROM ubuntu:18.04

ENV RUNNING_IN_DOCKER true
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN export DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND noninteractive

# Update the container #######################################################################################################

RUN apt-get -y update
RUN apt-get -y install build-essential
RUN apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev
RUN apt-get -y install curl zip unzip
RUN apt-get -y install software-properties-common
RUN apt-get -y install gnupg2
RUN apt-get -y install whois

#### SYSTEM ############################################################

RUN apt-get update
RUN apt-get install -y vim
RUN apt-get install -y nano
RUN apt-get install -y curl
RUN apt-get install -y git
RUN apt-get install -y wget
RUN apt-get install -y build-essential
RUN apt-get install -y cmake
RUN apt-get install -y zlib1g-dev
RUN apt-get install -y libcppunit-dev
RUN apt-get install -y libzip-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y libicu-dev
RUN apt-get install -y libssl-dev
RUN apt-get install -y libz-dev
RUN apt-get install -y libxml2-dev
RUN apt-get install -y libmemcached-dev
RUN apt-get install -y unzip
RUN apt-get install -y apt-utils
RUN apt-get install -y memcached
RUN apt-get install -y openssl
RUN apt-get install -y zsh
RUN apt-get install -y w3m
RUN apt-get install -y net-tools

# SHELL ####################################################################################

RUN chsh -s $(which zsh)
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN chsh -s $(which zsh) $(whoami)

# PHP 7.3 ##############################################################################################################

RUN add-apt-repository ppa:ondrej/php
RUN apt-get update

RUN apt-get -y install php7.3
RUN apt-get -y install php7.3-fpm
RUN apt-get -y install php7.3-cli
RUN apt-get -y install php7.3-json
RUN apt-get -y install php7.3-pdo
RUN apt-get -y install php7.3-mysql
RUN apt-get -y install php7.3-zip
RUN apt-get -y install php7.3-gd
RUN apt-get -y install php7.3-mbstring
RUN apt-get -y install php7.3-curl
RUN apt-get -y install php7.3-dev
RUN apt-get -y install php7.3-xdebug
RUN apt-get -y install php7.3-xml
RUN apt-get -y install php7.3-bcmath

RUN apt-get -y install php-pear
RUN apt-get -y install phpunit

RUN apt-get -y purge php8.*
RUN apt-get -y autoclean
RUN apt-get -y autoremove

# Apache ###################################################################################

RUN apt-get install -y apache2

# activation Apache MPM Event for FPM
RUN a2dismod php7.3
RUN a2dismod mpm_prefork
RUN a2enmod mpm_event

# installation FPM
RUN apt-get install -y php7.3-fpm
RUN apt-get install -y libapache2-mod-fcgid
RUN a2enconf php7.3-fpm
RUN a2enmod proxy
RUN a2enmod proxy_fcgi
RUN a2enmod actions
RUN a2enmod fcgid
RUN a2enmod alias

#RUN sed -i 's/listen = \/run\/php\/php7.3-fpm.sock/listen=127.0.0.1:9000/' /etc/php/7.3/fpm/pool.d/www.conf

# activation module apache
RUN a2enmod ssl
RUN a2enmod rewrite
RUN # a2enmod proxy_balancer
RUN # a2enmod proxy_http
RUN # a2enmod proxy_ajp

RUN mkdir /var/log/apache2/project-name
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

RUN apt-get -y install memcached
RUN apt-get -y install php-memcached

COPY server//apache//sites-enabled//project-name.conf /etc/apache2/sites-available

RUN apt-get -y purge php8.*
RUN apt-get -y autoclean
RUN apt-get -y autoremove

RUN a2dissite 000-default
RUN a2ensite project-name

EXPOSE 80
EXPOSE 443

#CMD /usr/sbin/apache2ctl -D FOREGROUND
#CMD service apache2 start

#CMD ["apache2ctl", "-D","FOREGROUND"]

## NODE JS #########################################################################

RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs

ENTRYPOINT ["tail", "-f", "/dev/null"]

What is wrong with this install of PHP-FPM or how can I switch php.ini for PHP config ?

Nothing is wrong. When you run PHP from the CLI ( php -i ), it will load the CLI configuration. The FPM configuration is only loaded when you access PHP through the FPM, that is the whole reason why there are two config files to change, because you may want to have different values on CLI and FPM.

When you access a website through apache in your browser or via curl, and you do

<?php phpinfo();

you'll see that the fpm.ini is loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM