Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
Observation
- PHP 7 was released on December 3, 2015
- PHP 7 is not available in the Ubuntu 12.04 (Precise) official repositories
- PHP 7.0 is available for Trust.
Prerequisites
sudo apt-get install build-essential autoconf libxml2-dev libicu-dev libssl-dev libsslcommon2-dev \
libcurl4-openssl-dev pkg-config libmcrypt-dev libreadline-dev unar p7zip-full libbz2-dev \
libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libgmp-dev libfreetype6-dev libgmp-dev libmcrypt-dev \
libpspell-dev libzip-dev php5-intl
Instalation / Configuration
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql
sudo apt-get install -y php7.1 php7.1-fpm php7.1-mysql
sudo apt-get install -y php7.2 php7.2-fpm php7.2-mysql
sudo apt-get install -y php7.3 php7.3-fpm php7.3-mysql
sudo apt-get install -y php7.0-mcrypt php7.1-mcrypt
sudo apt-get install -y php7.0-mbstring php7.1-mbstring php7.2-mbstring php7.3-mbstring
sudo apt-get install -y php7.0-xml php7.1-xml php7.2-xml php7.3-xml
sudo apt-get install -y php7.0-curl php7.1-curl php7.2-curl php7.3-curl
sudo apt-get install -y php7.0-json php7.1-json php7.2-json php7.3-json
NOTE: You can use the following command to list available PHP 7.1 packages:
sudo apt-cache search php7-*
Testing
We can check and set the version of the php interpreter that is used by the command line.
sudo update-alternatives --list php
We can then set the default command line interpreter using update-alternatives.
sudo update-alternatives --set php /usr/bin/php7.3
Running
We can also run a script on a specific version of the php runtime by specifying the interpreter on the command line /path/to/desired/php/interpreter /path/to/your/script.
/usr/bin/php5 /home/andy/myscript.php
Modules
You will need to disabled the Apache PHP5 module and enabled the PHP7.0 module.
sudo a2dismod php5
sudo a2enmod php7.3
sudo service apache2 restart
PHP Version
php -v
Add Comment
Please, Sign In to add comment