Skip to content

Instantly share code, notes, and snippets.

@zuhairkareem
Last active March 24, 2021 05:24
Show Gist options
  • Save zuhairkareem/50ba7d18f0a7918e5e6290b42387fc47 to your computer and use it in GitHub Desktop.
Save zuhairkareem/50ba7d18f0a7918e5e6290b42387fc47 to your computer and use it in GitHub Desktop.
Upgrading php 5.5.9 to php 7.1 in Ubuntu 14.04 LTS

Add the PPA

sudo add-apt-repository ppa:ondrej/php

Update repos

sudo apt-get update

Upgrade or downgrade PHP version

sudo update-alternatives --set php /usr/bin/php7.2 

I got depencancy error while i was installing PHP 7.1, so i had to install the dependancies first.

Install the necessary packages

sudo apt-get install libapache2-mod-php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache libssl1.0.2 php7.1-readline php-common php7.1-xml php7.1-mbstring php7.1-mysql php7.1-gd php7.1-curl

If "E: Package 'libssl1.0.2' has no installation candidate" error - change libssl1.0.2 to libssl1.0.0

Disable php5 modules present

sudo a2dismod php5

Enable php7.1 module

sudo a2enmod php7.1

Restart Apache

sudo service apache2 restart

Ref:- https://askubuntu.com/questions/760907/upgrade-to-16-04-php7-not-working-in-browser

PHP is not parsed in Virtual hosts present in user directories. This is because it is off by default for user directories.

Edit this file

 sudo vim /etc/apache2/mods-available/php7.1.conf

and comment these lines

<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

Restart apache

sudo service apache2 restart

-------- If the above doesn't help do this

PHP could be disabled for the virtual hosts. Try enabling it with "php_admin_flag engine on":

<VirtualHost *:80>
    DocumentRoot "/Library/Server/Web/Data/Sites/Gradschool"
    ServerName gradschool.local

    <Directory /Library/Server/Web/Data/Sites/Gradschool>
            php_admin_flag engine on
            AllowOverride AuthConfig FileInfo
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

Ref : https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-ubuntu-14-04

https://askubuntu.com/questions/967678/php-not-working-after-upgraded-to-ubuntu-17-10

libapache2-mod has been upgraded from libapache2-mod-php7.0 in Ubuntu 17.04 to libapache2-mod-php7.1 in Ubuntu 17.10 and Ubuntu 18.04. Open the terminal and type:

sudo apt-get install libapache2-mod-php7.1 # install PHP7 module for Apache2 webserver
sudo a2enmod php7.1 # enable the PHP7 module
sudo systemctl restart apache2.service # restart apache
@FirmanKurniawan
Copy link

anjing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment