Lubuntu 17.10 artful aardvark comes with php version 7.1 in the repository, but if you want to have the old php 5.6 back, probably because you are working on a project which works well on php 5.6 but not working very well on php 7.1, then installing php 5.6 is make sense.
If you already install php 7.1 on lubuntu, you don't need to uninstall it, the php 5.6 will automatically replace the php 7.1, even more great you can switch back and forth between the two, which i will show later in this tutorial.
How to install PHP 5.6 on Lubuntu 17.10
- open command line/terminal on lubuntu
- add ppa repository ondrej/php
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
php -v
You probably need to install some of the most important php modules such as mbstring, curl, gd, mcrypt, xml and so on. If you previously install those on php 7.1 you need to install it again for php 5.6, error message from your php application can show which php module that you need to install.
List of modules for php 5.6
php5.6-bcmath
php5.6-dba
php5.6-imap
php5.6-mcrypt
php5.6-pspell
php5.6-sybase
php5.6-bz2
php5.6-dev
php5.6-interbase
php5.6-mysql
php5.6-readline
php5.6-tidy
php5.6-cgi
php5.6-enchant
php5.6-intl
php5.6-odbc
php5.6-recode
php5.6-xml
php5.6-cli
php5.6-fpm
php5.6-json
php5.6-opcache
php5.6-snmp
php5.6-xmlrpc
php5.6-common
php5.6-gd
php5.6-ldap
php5.6-pgsql
php5.6-soap
php5.6-xsl
php5.6-curl
php5.6-gmp
php5.6-mbstring
php5.6-phpdbg
php5.6-sqlite3
php5.6-zip
How to switch back from php 5.6 to php 7.1
The great thing is you can go back to php 7.1 easily, without uninstalling anything, but first you need to understand that there are two level where php works, first on the web server level and second on the command line level.
web server level
sudo a2dismod php5.6
sudo a2enmod php7.1
sudo service apache2 restart
command line level
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
No comments:
Post a Comment