3

Where does the /etc/php/7.0/apache2/php.ini file come from on Ubuntu 16.04?

dpkg -S /etc/php/7.0/apache2/php.ini

returns nothing.

dpkg -S /etc/php/7.0/apache2/

shows that the directory is installed by the libapache2-mod-php7.0 package, but

dpkg-query -L libapache2-mod-php7.0

does not mention "php.ini". I'm guessing that this file is copied during a postinstall process. Is there a way to determine which package installation is creating this file?

1 Answers1

4

When you are searching for the how something got on your system often you might just want to try a command like this grep 'php.ini' /var/lib/dpkg/info/*. The /var/lib/dpkg/info/ contains files related to packages, which include the packagename.list which is used by the dpkg -S, the packagename.conffiles which is a list of the conffiles, and the files for the various pre/post install/remove scripts like packagename.actionname.

# grep 'php.ini' /var/lib/dpkg/info/*

/var/lib/dpkg/info/libapache2-mod-php7.0.postinst:    phpini="/etc/php/7.0/apache2/php.ini"
/var/lib/dpkg/info/libapache2-mod-php7.0.postinst:  ucf /usr/lib/php/7.0/php.ini-production.apache2 $phpini
/var/lib/dpkg/info/libapache2-mod-php7.0.postinst:  ucf /usr/lib/php/7.0/php.ini-production $phpini
/var/lib/dpkg/info/libapache2-mod-php7.0.postrm:    phpini=/etc/php/7.0/apache2/php.ini
/var/lib/dpkg/info/php7.0-cli.postinst:    phpini="/etc/php/7.0/cli/php.ini"
...

# cat /var/lib/dpkg/info/libapache2-mod-php7.0.postinst
...
if [ "$1" = "configure" ]; then
    phpini="/etc/php/7.0/apache2/php.ini"

    if [ "apache2" = "cli" ]; then
    ucf /usr/lib/php/7.0/php.ini-production.apache2 $phpini
    else
    ucf /usr/lib/php/7.0/php.ini-production $phpini
    fi
    ucfr libapache2-mod-php7.0 $phpini
...

Anyway for this particular query we see that the php.ini is being added via ucf from /usr/lib/php/7.0/php.ini-production. UCF is one of a few tools that can be used by Debian packages to maintain configuration files. UCF can accept some values from users to be merged in, it can detect and auto-update or merge configurations in some situations and so on.

Zoredache
  • 130,897
  • 41
  • 276
  • 420