Where is php.ini being loaded from in this instance of Docker?

Asked

Viewed 4,601 times

3

I’m running an instance that comes from this Dockerfile.

Here’s some of my phpinfo:

inserir a descrição da imagem aqui

As we can see Configuration File (php.ini) Path is pointing to /usr/local/etc/php. This value was passed on line 31 of the Dockerfile ENV PHP_INI_DIR /usr/local/etc/php.

But inside my /usr/local/etc/ subfiles I can’t find any php.ini:

inserir a descrição da imagem aqui

As we can see in phpinfo o Loaded Configuration File is empty.

I don’t know where the settings on this page are coming from. Where php.ini is being loaded from?

I also don’t see the php service to try to restart it: inserir a descrição da imagem aqui

UPDATE: I have php.ini in this folder:

inserir a descrição da imagem aqui

This is the Dockerfile:

FROM php:5-apache

# Update apt-get
RUN apt-get update

## list of installed library packages only =>  https://askubuntu.com/questions/434154/how-to-get-the-list-of-installed-library-packages-only
#ldconfig -v                # -v it will show the libraries versions
#ldconfig -v | grep libname # Use grep to find a specific library by name.
#RUN /sbin/ldconfig -p

## ListInstalledPackages => https://wiki.debian.org/ListInstalledPackages
#RUN dpkg-query -l

## NOTE:
##need setup php variables date and maxupload file and others variables. ==> https://howto.biapy.com/en/debian-gnu-linux/servers/php/manage-php-ini-options-from-command-line-on-debian

##Install FFmpeg on Debian  => https://superuser.com/questions/286675/how-to-install-ffmpeg-on-debian
#https://www.johnvansickle.com/ffmpeg/
## System modules


#RUN apt-get install deb-multimedia-keyring
#RUN apt-get update
#RUN apt-get install -y ffmpeg


## UTILITIES
RUN apt-get install -y vim
#RUN apt-get install -y wget


## APACHE2  basic installation
RUN apachectl -M
RUN a2enmod rewrite
RUN a2enmod expires
RUN service apache2 restart
RUN apachectl -M


################################################
## PHP modules
## Note: when installing from php5 for some modules we need to copy from php5/mods-available to local/etc/php/conf.d and create a simbolic link

RUN php -m

RUN apt-get install -y php5-common

RUN apt-get install -y php-calendar
#RUN cp /etc/php5/mods-available/calendar.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/calendar.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/calendar.so

#RUN docker-php-ext-install calendar 

RUN docker-php-ext-install bcmath

RUN apt-get install -y php5-mhash
#RUN cp /etc/php5/mods-available/mhash.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mhash.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mhash.so

RUN apt-get install -y php5-intl
RUN cp /etc/php5/mods-available/intl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/intl.so

RUN apt-get install -y php5-mcrypt
RUN cp /etc/php5/mods-available/mcrypt.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mcrypt.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mcrypt.so

RUN apt-get install -y php5-redis
RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so

RUN apt-get install -y php5-mysql
RUN cp /etc/php5/mods-available/mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysql.so

RUN cp /etc/php5/mods-available/opcache.ini /usr/local/etc/php/conf.d

RUN apt-get install -y php5-gd
RUN cp /etc/php5/mods-available/gd.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gd.so

RUN apt-get install -y php5-gdcm
RUN cp /etc/php5/mods-available/gdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gdcm.so

RUN apt-get install -y php5-vtkgdcm
RUN cp /etc/php5/mods-available/vtkgdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/vtkgdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/vtkgdcm.so

RUN apt-get install -y php5-ldap
RUN cp /etc/php5/mods-available/ldap.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ldap.so

RUN apt-get install -y php5-xsl
RUN cp /etc/php5/mods-available/xsl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xsl.so

RUN apt-get install -y php5-tidy
RUN cp /etc/php5/mods-available/tidy.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/tidy.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/tidy.so

RUN apt-get install -y php5-xmlrpc
RUN cp /etc/php5/mods-available/xmlrpc.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xmlrpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xmlrpc.so

RUN apt-get install -y php5-pgsql
RUN cp /etc/php5/mods-available/pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pgsql.so


RUN cp /etc/php5/mods-available/mysqli.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysqli.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli.so
RUN cp /etc/php5/mods-available/pdo.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo.so
RUN cp /etc/php5/mods-available/pdo_mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so
RUN cp /etc/php5/mods-available/pdo_pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_pgsql.so
RUN cp /etc/php5/mods-available/readline.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/readline.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/readline.so

#RUN apt-get install -y php5-snmp
#RUN cp /etc/php5/mods-available/snmp.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/snmp.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/snmp.so


RUN php -m


## REDIS
RUN apt-get install -y telnet redis-server
RUN apt-get install -y redis-server
RUN apt-get install -y npm

#RUN mkdir /composer-setup && mkdir /usr/local/bin/composer && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/local/bin/composer && rm -Rf /composer-setup




################################################
## PHP extra modules
#RUN apt-get install -y php-horde-date-parser  ##The command '/bin/sh -c apt-get install -y php-horde-date-parser' returned a non-zero code: 100
#RUN apt-get install -y php-horde-date
#RUN apt-get install -y php-horde-timezone
#RUN apt-get install -y php-horde-timeobjects
#RUN apt-get install -y php-timer



#RUN apt-get install -y php-horde-icalendar
#RUN apt-get install -y php-horde-kronolith
#RUN apt-get install -y php-doctrine-dbal
#RUN apt-get install -y phpldapadmin
#RUN apt-get install -y php-horde-ldap
#RUN apt-get install -y php-net-ldap
#RUN apt-get install -y php-net-ldap2
#RUN apt-get install -y php-mdb2-driver-pgsql
#RUN apt-get install -y libnusoap-php
#RUN apt-get install -y php-soap
#RUN apt-get install -y php-fxsl
#RUN apt-get install -y php-horde-text-filter-csstidy
#RUN apt-get install -y php-pclzip
#RUN apt-get install -y libphp-pclzip

#RUN apt-get update

#RUN cp /etc/php5/mods-available/json.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/json.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/json.so


#Manage PHP ini options from command line on Debian => https://howto.biapy.com/en/debian-gnu-linux/servers/php/manage-php-ini-options-from-command-line-on-debian
#RUN apt-get install -y php5-cli


### Note: Compare content

#PHP5
#cd /usr/local/etc/php/conf.d
#cd /etc/php5/mods-available/


#PHP 
#cd /usr/local/lib/php/extensions/no-debug-non-zts-20131226
#cd /usr/lib/php5/20131226/



## Note: when module is php5 need to make it available inside php/extensions (create a simbolic link)
#RUN cp /etc/php5/mods-available/MODULE.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/MODULE.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/MODULE.so

################################################






## WORK DIR
#COPY manyvids/ /var/www/html
#COPY src/ /var/www/html

# CONNECTIONS - PORTS
#EXPOSE 80

#########################################. Extra notes
#CMD ["redis-server"]

## Clean up Docker
#docker rm $(docker ps -a)
#docker rmi $(docker images)
#docker build -t mv1_img . 

## RUN REDIS 
#Open up another terminal
#docker  exec -it  xxxxxCOntainerId bash 
#root@bxxxxxCOntainerId:/var/www/html# redis-server

#If another terminal is needed to get acces to the container:
#Open up another terminal
#docker  exec -it  xxxxxCOntainerId bash 


## Not found modules. We have it in MAMP instance, not in DOCKER apt php list and not in php -m
#mysqli
#pdo_mysql
#pdo_pgsql
#shmop
#sockets
#sysvmsg
#sysvsem
#sysvshm
#wddx

2 answers

1

See the example of how PHP.ini should be loaded in the library’s own documentation in PHP in Docker:

FROM php:7.2-fpm-alpine

# Use the default production configuration
RUN mv $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini

# Override with custom opcache settings
COPY config/opcache.ini $PHP_INI_DIR/conf.d/

In this example the author chose to use the production configuration, so he renamed the php.ini-Production file to php.ini. So in your case if there is a file /usr/local/etc/php/php.ini this is where PHP will get the configuration. And the folder /usr/local/etc/php/conf. d/ is for the extension settings, as in the example above is being used a configuration of the option.

If you want to use a configuration of your own, just copy it from your directory to the PHP configuration folder. Example:

COPY config/php.ini $PHP_INI_DIR/php.ini

Follow the documentation link: doc

0

You can validate php get with the installation cycle from 108 to 151 dockerfile.

Try fetching the . ini in /etc/php/5.6/.... must be there, but inside the box q vc created, then make the attach Id_docker_file p access.

Have q check if sapi was installed, maybe missing pq did not see in the file the wget or apt-get from it, where you could use fpm.

If you have any problem p up app sends in the coments.

  • Hi Luiz, after your idea I did a search and found php.ini inside the mentioned file. But I’m not understanding how this file is not being considered when we display php.ini settings in the browser. I’ll post my full Dockfile.

  • I think I understand part of the problem. It seems that the official Dockerfile, is installing php5.6 within /etc/php5/cli/php.ini and then on line 31 he points out ENV PHP_INI_DIR /usr/local/etc/php. He expects this directory to have a php.ini file. I think I should then create a symbolic link in /usr/local/etc/php pointing to /etc/php5/cli/php.ini But I still don’t understand where this php.ini is being loaded from.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.