How to Switch between Multiple PHP Version and install phpmyadmin on Ubuntu 12.04,14.04 and 16.04
How to Switch between Multiple PHP Version and install phpmyadmin on Ubuntu 12.04,14.04 and 16.04
Install PHP 5.6 on Ubuntu
Use the following set of command to add PPA for PHP 5.6 in your Ubuntu system and install PHP 5.6.
Check Installed PHP Version:
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Install PHP 7.1 on Ubuntu
Use the following set of command to add PPA for PHP 7.1 in your Ubuntu system and install PHP 7.1.
Check Installed PHP Version:
PHP 7.1.0-5+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0-5+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
Install it via wget and create an alias in Apache. Keep track:
Change to directory /usr/share:
We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the "web root". In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:
The address you want to visit will be:
Install PHP 5.6 on Ubuntu
Use the following set of command to add PPA for PHP 5.6 in your Ubuntu system and install PHP 5.6.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php5.6
Check Installed PHP Version:
php -vPHP 5.6.29-1+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Install PHP 7.1 on Ubuntu
Use the following set of command to add PPA for PHP 7.1 in your Ubuntu system and install PHP 7.1.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php7.1
Check Installed PHP Version:
php -v
PHP 7.1.0-5+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0-5+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
Switch PHP version:
From php5.6 to php7.1:sudo a2dismod php5.6 ; sudo a2enmod php7.1 ; sudo service apache2 restartFrom php7.1 to php5.6:
sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart
How to install phpmyadmin on PHP7 Apache/2.4.7 (Ubuntu)?
Install it via wget and create an alias in Apache. Keep track:
Change to directory /usr/share:
cd /usr/shareChange to root user:
sudo suDownload phpMyAdmin:
wget https://files.phpmyadmin.net/phpMyAdmin/4.5.4.1/phpMyAdmin-4.5.4.1-all-languages.zipUnzip it: (you may install unzip first)
unzip phpMyAdmin-4.5.4.1-all-languages.zipRename the folder:
mv phpMyAdmin-4.5.4.1-all-languages phpmyadminChange permissions:
chmod -R 0755 phpmyadminConfigure apache so that it can find it correctly:
gedit /etc/apache2/sites-available/000-default.confAnywhere after "DocumentRoot /var/www/html" insert these line:
Alias /phpmyadmin "/usr/share/phpmyadmin/"Restart Apache:Order allow,deny Allow from all Require all granted
service apache2 restartIn order to test that our system is configured properly for PHP, we can create a very basic PHP script.
We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the "web root". In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:
sudo nano /var/www/html/info.phpThis will open a blank file. We want to put the following text, which is valid PHP code, inside the file:
<?php phpinfo(); ?>When you are finished, save and close the file.
The address you want to visit will be:
http://your_server_IP_address/info.php OR http://localhost/info.php
No comments: