I m trying to install php 5.5 and php5-memcached for my machine which has php 5.3 pre-installed. Also, I can not change default configuration as it is staging box provided for CI.So let's assume php 5.3 is pre-installed and that can not be changed.

So, first thing first I try to install php, then php-memcached:

sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confnew" -o Dpkg::Options::="--force-overwrite" install -y php5
sudo apt-get -o Dpkg::Options::="--force-confnew" -o Dpkg::Options::="--force-overwrite" install -y php5-memcached

The important thing is that commands above are invoked by build runner, therefore, it is not "interactive" mode as there is no "user" who is taking care of installation.

The problem is that because of existing php 5.3 I'm getting:

(B)0Package configuration┌──────────────────────┤ Modified configuration file ├──────────────────────┐│ A new version of configuration file /etc/php5/cli/php.ini is available, ││ but the version installed currently has been locally modified.││││ What do you want to do about modified configuration file php.ini?││││install the package maintainer's version││keep the local version currently installed ││show the differences between the versions││show a side-by-side difference between the versions││start a new shell to examine the situation│││││││││└───────────────────────────────────────────────────────────────────────────┘

That is because it found some modified config file. And the question is - can I somehow force it to be overwritten? As you can see, I already tried -o Dpkg::Options::="--force-confnew" -o Dpkg::Options::="--force-overwrite" without any success (I suppose that's because this "dialog" is not related to dpkg). The issue with this "dialog" is, obviously, in the fact, that all setup commands are invoked from inside CI container, and there is no "user" who can do any "action" - it should be completely automatic execution.


Question: How can I force overwriting any configs in this case? Or else, how can I achieve initial goal and upgrade php from 5.3 to 5.5 and then install php5-memcached?


The message in question is not related to dpkg and so it is not possible to control it with dpkg options. There are two viable options as I found them:

  • First, completely reinstall PHP: remove PHP 5.3 first and then install 5.5 on "blank system". In my case this is not good solution as removing PHP 5.3 will take very long time (more than 500.000 files and corresponding checks)
  • Second, use phpenv and php-build for managing different PHP environments without touching currently installed one. By default, it is provided with pyrus extension which is for pyrus packet manager, which allows to use it. For php-memcached I used it simply as:

    pyrus install pecl/memcached-2.1.0
    pyrus build pecl/memcached-2.1.0
    phpenv rehash

    Note that pyrus install pecl/memcached may failed on some PHP versions, therefore, it is safer for the build to specify certain version of PHP. This method with pyrus will allow to install any package available for pyrus. If you still need something custom (I needed phalcon), you can build it with custom compilation, like:

    # get the extension via wget, for example
    # cd to extension directory
    # Perform the compilation
    ./configure --with-php-config=/home/ubuntu/.phpenv/versions/$PHPVERSION  /bin/php-config --enable-extension
    make && make install
    echo "extension=extension.so" > ~/.phpenv/versions/$PHPVERSION/etc/conf.d/extension.ini

    where --enable-extension, "extension.so" etc. you need yo replace with your compiled extension.

As you can see, this is not direct way to resolve a matter but it still corresponds a goal of fully automatic CI build allowing to create any PHP versions setup/extension enable for such builds.

P.S. If someone will find a way to overcome message in the question, this will be the "third" option, but I don't believe it's possible with dpkg tools.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.