Centos 8 PHP 56 - php

I am trying to install php 5.6 on centos 8. I understand it is no longer supported (eol), but due to an old project, it needs it.
I have tried:
sudo dnf --enablerepo=remi install php56
Installs with no issue, hitting localhhost/ throws an error
Running php --version gives me an error
bash: /usr/bin/php: No such file or directory
Howver running php56 --version works.
How do i make it such that any reference to php will use php56?

The Software Collections are designed for parallel installation of multiple versions. So you have to enable the collection of the version you want.
Example:
$ module load php80
$ php -v
PHP 8.0.9 (cli) (built: Jul 29 2021 12:53:58) ( NTS gcc x86_64 )
$ module load php56
$ php -v
PHP 5.6.40 (cli) (built: Jun 28 2021 00:00:00)
For web server, if only one version is installed, it will be used for all pages.
If multiple versions are installed you have to set the proper handler (socket path) for each vhost / project / directory to use the wanted FPM backend.
How do i make it such that any reference to php will use php56?
If you really need only one version, you can also install the php56-syspaths package, which provides /usr/bin/php (a symlink)

Related

Cant upgrade php version on MacOS Catalina

I have a very annoying problem. I have 2 versions of PHP on MacOS Catalina, and no matter what I do, I cant seem to get rid of the old (php 7.3.x) version. I can't change anything in /usr/bin/ on my Mac, even though I'm an admin user.
The 2 versions of PHP are:
$ /usr/bin/php -v
PHP 7.3.11 (cli) (built: Apr 17 2020 19:14:14) ( NTS )
$ /usr/local/bin/php -v
PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS )
Even though which php and php -v use 7.4:
$ which php
/usr/local/bin/php
$ php -v
PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS )
The problem is that when my cron job runs, it uses /usr/bin/php (version 7.3.x), making my cron job fail (turns out some Laravel package code - specifically Mailcoach - is not compiant with php 7.3.* and NEEDS php v 7.4 or above.
This is what my PATH variable looks like:
$ echo $PATH
/usr/local/bin/php:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:./vendor/bin:/usr/local/sbin:/Users/kunalpunjabi/.composer/vendor/bin:/usr/local/mysql/bin:/usr/local/bin/mysql
If you've encountered this before or know how to fix it, please help!
Did you install them trough homebrew?
If so try linking php7.4
First look at what php is currently running trough
brew services list
Then stop and unlink that version with
brew services stop {PHP}
brew unlink {PHP}
Then link the correct version
brew link --force --overwrite php#7.4
brew services start php#7.4
Could you try this?
If this not works, could you upload a screenshot of your 'brew services list'

XDEBUG installation reading wrong PHP version

I have an Ubuntu 16.04 vagrant box running on php 7.1. When I try to build xdebug by running ./configure in xdebug-2.6.0 I get
Check for supported PHP versions... configure: error: not supported. Need a PHP version >= 7.0.0 and < 7.3.0 (found 5.5.9-1ubuntu4.24)
PHP -v yields
Xdebug requires Zend Engine API version 320170718.
The Zend Engine API version 320160303 which is installed, is outdated.
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:27:08) ( NTS )
So the system is running 7.1, but for some reason the configure script thinks we're still on 5.5.9
I've hit google pretty hard, but still can't find a way to update the Zend engine either.
Any ideas?
It happens because you're configuring with default settings and that is different from the PHP version you're trying to configure.
Just like you saw the PHP version using the php -v command, check the php-config version using the php-config --version command, it should be the same as php -v, but in your case, it would be different and hence this issue.
Now let's talk about how we can solve it. Since you need a different version of config, you should point that to the configure command.
For example, in your case, you need php-config7.1 (because you're using PHP v7.1, similarly for 7.2 you have php-config7.2 and so on)
To point the configure command to a specific PHP version you need to specify that as a flag called with-php-config and the value should be the location of the php-config file, a sample would be
./configure --with-php-config=/usr/bin/php-config7.1
Hope this solves the problem.
I assume you run phpize before running ./configure. Instead you need to run phpize7.1 and then ./configure
if you don't have phpize7.1 installed you can install it via:
sudo apt install apt install php7.1-dev

Error installing Phalcon PHP: PHP 5.3 is no longer supported

I tried to install Phalcon PHP but I got an error
php 5.3 is no longer supported
I check PHP Version
$ php -v
return
PHP 7.0.25-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:43:45) ( NTS )
but I check in phpinfo();
PHP Version 5.6.32-1+ubuntu16.04.1+deb.sury.org+1
Phpinfo() will always show the version your server is currently running. You will need to change the php version that apache is using. You can do this by disabling PHP 5 module by checking your apcahe files or disabling with 'sudo a2dismod php5'. Then you will need to enable php 7 by allocating in your files or again enabling it with 'sudo a2enmod php7.1'. To see results you will need to restart apache. I hope this helps

different result between phpinfo.php and php-v

i was using appserv 5.8
and in my phpinfo.php the php version was 5.6.26
now i installed laravel5.5
and its required phpversion 7
so i changed the php version to 7 from 5
now in my phpinfo.php
PHP Version 7.0.11
and when i write in the command
php -v
its give me
PHP 5.6.26 (cli) (built: Sep 15 2016 18:12:07)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
and i cant install the packages with laravel 5.5 bc the version in command line is 5.6 not 7
but when i check in phpinfo its 7
i have read something thats the command php -v tack the version from php-cli
so how can i change the php -v to be 7.0.1 as phpinfo.php
thanks ..
phpinfo.php shows what version of PHP Apache is using. -v shows what's in your $PATH.
If you're on a Mac I recommend using homebrew to install php 7 as described here
To clarify, PHP can be run in 3 ways: behind a web server, for command line scripting, and for GUI building. You have 2 versions: the web server one, which Apache is calling and invoking phpinfo.php, and PHP-CLI, which is invoked from the command line with php -v.
It seems like your PHP CLI version is different than the PHP web version. Upgrade your PHP CLI package.
You have two PHP binaries installed. In my Mac OSX:
$ which php
/usr/local/bin/php
$ /usr/local/bin/php -v
PHP 7.0.20 (cli) (built: Jul 12 2017 09:47:44) ( NTS )
And in same machine:
$ whereis php
/usr/bin/php
$ /usr/bin/php -v
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
You should put /usr/local/bin in your PATH. Edit ~/.bash_profile
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Open a new terminal and check your php version.
For me(Windows) changing CLI version also didn't work, finally
changing PHP version at Environment Variable PATH worked!!

php56 - CentOS - Remi Repo

I just installed php 5.6 on a test box, and the normal cli php interpreter doesn't appear to exist:
$ -> php -v
-bash: php: command not found
$ -> php56 -v
PHP 5.6.13 (cli) (built: Sep 3 2015 13:41:04)
If I try to do a yum install php --enablerepo=remi then it tries to install php 5.4.
So it's obvious that php56 is a cli interpreter, but I've always been used to just typing php vs php56. Is this the new norm, or is there another step for installing php56 on CentOS (6.7)? Is it as simple as creating a symlink? ln -s /usr/bin/php56 /usr/bin/php
Steps to upgrade:
$ -> yum remove php* --enablerepo=remi
$ -> yum install php56* --enablerepo=remi
Thx to Remi for the push in the right direction, here's what my repo config looks like:
[upstream_remi54]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/remi/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[upstream_remi56]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/php56/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
This works well if you want to completely replace existing PHP, vs running versions in parallel. I have to keep PHP 5.4 in place for Roundcube and Postfix Admin, as some of the modules necessary for those to work have not yet been ported, so that server has to stay 5.4 for now.
php-* are base packages, 1 repository per version
"remi" => php 5.4
"remi-php55" => php 5.5
"remi-php56" => php 5.6
"remi-php70" => php 7.0 (Release Candidate, not ready for prod)
php56-* packages are Software Collections, parallel installation allowing to run multiple versions of PHP.
See : http://blog.remirepo.net/pages/English-FAQ
So, if you only want a single php version 5.6
yum --enablerepo=remi-php56 install php-cli (and other needed modules)
And you can also enable the repository for future update (as the "remi-php56" is safe and only provides php 5.6 and its extension)
yum-config-manager --enable remi-php56

Categories