I have built PHP 7.3.27 from source like this:

./configure --with-config-file-path=/etc/php7/cli \
--with-config-file-scan-dir=/etc/php7/cli \
 --with-openssl \
 --with-bz2 \
 --with-zlib \
 --with-bz2 \
 --with-sodium \
 --with-xsl \
 --with-readline \
 --enable-sockets \
 --enable-soap \
 --enable-mbstring \
 --enable-ftp \
 --enable-calendar \
 --enable-bcmath \
 --enable-pcntl \

and executed make && make install, then I restarted apache2.

But if I execute php -v then the old php version is still showing.

What steps am I missing to change the PHP CLI version?

  • 1
    Is $HOME/bin/php-latest/bin in your $PATH? That’s where you appear to have installed it. (With —prefix) – jsbillings Mar 3 at 1:07
  • No, it was not in my PATH. I added it now with PATH=$PATH:~/$HOME/bin/php-latest/bin it shows this now /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin:/usr/local/modman:/root//root/bin/php-latest/bin but If I execute php -v then I still get PHP 7.2.5 – Black Mar 3 at 9:17
  • /root//root/bin/php-latest/bin looks weird. Have I did something wrong? How can I fix it? – Black Mar 3 at 9:20
  • 1
    You said ~/$HOME/bin/php-latest/bin, not $HOME/bin/php-latest/bin. Either use ~ or $HOME, not both. – jsbillings Mar 3 at 14:25
  • How can I fix it? Is there a file where it is stored? I searched in etc/environment (?) i think, but my php-latest does not appear there. – Black Mar 3 at 14:50

Your Answer

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

Browse other questions tagged or ask your own question.