4

Problem

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:

A new version of configuration file /etc/php5/cli/php.ini is available, but the version installed currently has been locally
modified.

  1. install the package maintainer's version    3. show the differences between the versions            5. start a new shell to examine the situation
  2. keep the local version currently installed  4. show a side-by-side difference between the versions

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.

Again,

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?

1
  • Would it be possible to move/rename the existing php.ini file, then just copy/rename it back after install, overwriting the one created?
    – mbomb007
    Feb 13, 2023 at 19:24

1 Answer 1

0

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:

    #!/bin/bash
    
    PHPVERSION=$1
    
    # get the extension via wget, for example
    
    # cd to extension directory
    
    # Perform the compilation
    ~/.phpenv/versions/$PHPVERSION/bin/phpize
    ./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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .