DEV Community

Upgrading to PHP 7.4

Pushkar Anand on November 28, 2019

The awaited latest version of the PHP 7.4 was released on 28th Nov, 2019. It comes with a lot of new features such as Typed Properties Arrow Func...
Collapse
 
devvyd profile image
Dāvis Naglis

Good job.
Switched to PHP 7.4 yesterday. Ended up having a "MySQL server gone away" error when working with Laravel. Weirdly enough, the fix was to change MySQL authentication method to caching_sha2_password.

Collapse
 
anandpushkar088 profile image
Pushkar Anand

MySQL 8.X uses caching_sha2_password as the default authentication mechanism.

Collapse
 
devvyd profile image
Dāvis Naglis

I still had it on auth_socket as authentication mechanism (after I reinstalled MySQL).

Collapse
 
funnelxpert profile image
Peter Nyiri

Hi,
I am not an expert and having trouble updating to PHP 7.4 from 7.2.
I have a VPS, Apache-NGINX-Varnish, CentOS 7.7 and CWP Pro.
I did the steps to install:

sudo yum -y install dl.fedoraproject.org/pub/epel/epel...

sudo yum -y install rpms.remirepo.net/enterprise/remi-...

yum --enablerepo=remi-php74 install php

yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

sudo yum-config-manager --enable remi-php74

At this point php 7.4 seems to be installed, however php -v still returns 7.2 and CWP also shows the old version.

What else do I need to do to with Apache/NGINX?

Server version: Apache/2.4.6 (CentOS)
Server MPM: prefork

I tried this:

sudo apt install libapache2-mod-php7.4

sudo: apt: command not found

Thanks.

Collapse
 
anandpushkar088 profile image
Pushkar Anand

Try sudo dnf -y install dnf-utils and sudo dnf module install php:remi-7.4

Collapse
 
funnelxpert profile image
Peter Nyiri

I use yum, not dnf.

I already ran this:
sudo yum -y install yum-utils

Package yum-utils-1.1.31-52.el7.noarch already installed and latest version
Nothing to do

Also I just remembered that my server is running on php-cgi, not php-fpm

Thread Thread
 
anandpushkar088 profile image
Pushkar Anand

I have no experience with CGI.

Collapse
 
webmarielle profile image
Marielle • Edited

Hello, Petter. I have the same trouble with updating PHP on CWP. Can you possibly write me if you finded the solution?

Collapse
 
hungnguyenkt profile image
Hung Nguyen Manh

hahahaha it's like TypeScript systax

Collapse
 
leslieeeee profile image
Leslie

If you are a macOS user, ServBay.dev is worth to try. You don't need to spend some time or couple of days to setup anything. Just download it and you can use it immediately. You can run multiple PHP versions simultaneously and switch between them effortlessly.
Honestly, this tool has greatly simplified my PHP development and is definitely worth trying!

Collapse
 
codestuff2 profile image
Adam Whitlock

Php is looking a bit more like typescript with all the typing and arrow functions! Thanks for writing

Collapse
 
jeremycmorgan profile image
Jeremy Morgan

Very cool stuff. I haven't coded anything real in PHP in about a decade but I'm thinking about putting something together just for fun. Thanks for the article!

Collapse
 
anandpushkar088 profile image
Pushkar Anand

Do post about what you build.

Collapse
 
dmitridon profile image
Dmitri Don

php7.4-fpmpackage -> php7.4-fpm package

also, would be cool if you would publish how all these new features would change our code!

Collapse
 
anandpushkar088 profile image
Pushkar Anand

Thanks for finding the typo. I plan on writing about it shortly.

Collapse
 
madhavassociate profile image
Injection Moulding

Hi pushkar, can you tell me how can I install ziparchive on php 7.4? i am running virtuamin on centos 7.

Collapse
 
anandpushkar088 profile image
Pushkar Anand

I am not that familiar with virtuamin, but I think it should be same as installing any other packages. Try installing as you usually do. The ziparchive is available in php-zip.

Collapse
 
natanfelles profile image
Natan Felles • Edited

How do you installed xdebug?

Collapse
 
anandpushkar088 profile image
Pushkar Anand

I used the pear package to install Xdebug.

Collapse
 
kstka profile image
Konstantin

Thank you for the article. There is a tiny mistake here (php7.3):

sudo apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.3-readline php7.3-zip

Collapse
 
anandpushkar088 profile image
Pushkar Anand

Thanks for letting me know. I'll update.