Upgrade to PHP 7.4 from PHP 2.0

This is the upgrade of my previous post . Previously, I showed how to upgrade to 7.2. Now, it’s time for one more jump to new version.

The latest version of PHP comes with a couple of changes

More details: http://php.net/releases/7_4_0.php

Even it’s your first time, just follow the following steps. First, update your system.


sudo apt-get update
sudo apt-get install python-software-properties

Second, add Ondřej’s PPA to the system’s Apt sources:

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

Update your local package cache again

sudo apt-get update

Now Install PHP 7.4

sudo apt-get install php7.4

In order to version check, run:
php -v

You also need to install some modules

sudo apt-get install libapache2-mod-php7.4 php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-imap php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-pspell php7.4-readline php7.4-soap php7.4-xml php7.4-zip

One more module for Nginx server

sudo apt-get install php7.4-fpm

You can check whether the installation is successful or not.

php-fpm7.4 -v

Attention:

You can ignore the following steps if you install PHP 7.4 for the first time.

For Nginx Server

Update the unix socket path at default configuration as well as other configurations.

/var/run/php/php7.4-fpm.sock

Check the Nginx configuration

sudo nginx -t

Restart the Nginx server

sudo service nginx restart

 

For Apache server

You need to disable the old version on Apache and tell Apache to use PHP 7.4.

sudo a2dismod php7.2  
sudo a2enmod php7.4

Restart the Apache server

sudo /etc/init.d/apache2 restart

 

Last Part, update the php ini for better performance in web application

Update the following values in php.ini. php.ini  located in /etc/php/7.4/fpm/php.ini for Nginx and located in /etc/php/7.4/apache2/php.ini for apache.

upload_max_filesize = 32M 
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

 

Now, you can remove the old version

sudo apt-get install ppa-purge
sudo apt-get purge php7.2-common

Happy hacking 🙂

 

Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Read previous post:
Backup your Seagate Personal Cloud to pCloud

I was looking for a proper solution to take the backup of my Seagate Personal Clould (NAS server) to another...

Close