back_image
blog-image

Update PHP to 7.3 and use Multiple PHP on Same Server on Ubuntu 18.04

Author Image By Ashish Dwivedi

May 24, 2019

2 minutes

How to Upgrade PHP to php7.3 and use Multiple PHP Version on Ubuntu 18.04

Recently you started gettings warning to upgrade PHP, you are still at 5.6, you may look at end of life timelines.

https://www.php.net/eol.php

So you now you already know the time for 5.6 and 7.0 passed out months ago.

So let us plan to upgrade PHP to latest ie 7.3. Which comes with several security patches. As a great upgrade strategy, Always Backup 100% first. So keep everything backup including databases.

Update PHP to 7.3 and use Multiple PHP on Same Server on Ubuntu 18.04

At Ubuntu , with my personal experience, beforing starting any upgrade, always start with 2 commands.

1) Become Sudo user with command “sudo su” and than

     apt-get update    
     apt-get upgrade

2) Now time to include Ondrej PPA

     sudo apt-get install software-properties-common
     sudo add-apt-repository ppa:ondrej/php
     apt-get update

 3) Now install PHP and it’s Extensions.

     apt-get install php7.3
     apt-get install libapache2-mod-php7.3
     sudo apt-get install php7.3 php7.3-cli php7.3-common
     sudo apt-get install php7.3-json php7.3-opcache 
     sudo apt-get install php7.3-mysql
     sudo apt-get install php7.3-bcmath php7.3-xml
     sudo apt-get install php7.3-curl php7.3-imap php7.3-gd

4) Now time to modify php.ini to enhance server performance

     cd /etc/php/7.3/apache2
     nano php.ini
     memory_limit ( 40 - 50 % of Memory), 
     max_file_uploads (20 - 50), 
     post_max_size (40 - 50 % of Memory), 
     max_execution_time (3600) , 
     upload_max_filesize ( 40 - 50 % of Memory), 
     max_input_time = 1000

5) Now disable old php and enable new php version

     a2dismod php5.6  or a2dismod php7.0
     a2enmod php7.3

6) Time to restart Apache

     Service apache2 restart

7) Now type php -v or php –version

You should get a message like this

 PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May  3 2019 10:00:24) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies

with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999- 2018,  by Zend Technologies

As you already have seen, you have php 7.3 , go to the webroot of server ie /var/www/html , Create a file info.php.

Put this content  into this file

      

Now reach to this file via browser ie https://mydomain/info.php

So your command line PHP (PHP-CLI) and PHP on browser must be the same version. ie php7.3 in our case.

Now if you want to use different PHP for different websites, Go this article..

To be summarised, Keeping continuous upgrades of software and servers , pushing you ahead in the competition, as new upgrades come with security upgrades and patches. Also It has seen significant speed improvements after upgrades.


1 Comment

Nakliye · December 17, 2023 at 11:46 am

Hi there, constantly i used to check web site posts here in the early hours in the break of
day, since i love to gain knowledge of more and more.

Leave a Reply

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

© OutRight Systems 2024 - We are doing IT Right! This website is property of OutRight Systems and it has copyright.

Disclaimer: The website outrightsystems.org is owned and operated by OutRight Systems Pvt Ltd and not affiliated with SugarCRM, Inc. or SuiteCRM. SugarCRM® is a registered trademark of SugarCRM, Inc.