Based on this tutorial: https://www.cyberciti.biz/faq/installing-php-7-on-debian-linux-8-jessie-wheezy-using-apt-get
sudo apt-get install git
cd /tmp
git clone https://github.com/kasparsd/php-7-debian.git
cd php-7-debian/
You can read more here: https://www.mediawiki.org/wiki/PHP_configuration
Use vim build.sh
command to edit build.sh script
You’ll need to add line --with-apxs2=/usr/bin/apxs2 \
to your CONFIGURE_STRING and place make clean
before make command.
CONFIGURE_STRING="--prefix=/usr/local/php7 \
--enable-huge-code-pages \
--with-apxs2=/usr/bin/apxs2 \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--enable-intl \
--enable-exif \
--enable-dba \
--enable-ftp \
--with-gettext \
--with-gd \
--with-jpeg-dir \
--enable-mbstring \
--with-mhash \
--enable-mysqlnd \
--with-mysqli \
--with-mysql-sock=yes \
--with-pdo-mysql \
--with-openssl \
--enable-pcntl \
--with-pspell \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-zlib \
--enable-zip \
--with-readline \
--with-curl \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data"
./configure $CONFIGURE_STRING
make clean
make -j "$JOB_COUNT"
Reference [ru] https://habr.com/company/plesk/blog/306682/
$ update-alternatives --install /usr/local/bin/php php /usr/bin/php5 10x
update-alternatives: using /usr/bin/php5 to provide /usr/local/bin/php (php) in auto mode
$ update-alternatives --install /usr/local/bin/php php /usr/local/php7/bin/php 20
update-alternatives: using /usr/local/php7/bin/php to provide /usr/local/bin/php (php) in auto mode
Use /usr/local/bin/php
instead of /usr/bin/php
$ sudo rm /usr/bin/php
$ update-alternatives --config php
update-alternatives: warning: /etc/alternatives/php is dangling; it will be updated with best choice
There are 2 choices for the alternative php (providing /usr/local/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/local/php7/bin/php 20 auto mode
1 /usr/bin/php5 10 manual mode
Press enter to keep the current choice[*], or type selection number: 0
$ sudo ln -s /usr/local/bin/php /usr/bin/php
$ php -v
PHP 7.2.12 (cli) (built: Jan 15 2019 04:15:05) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.12, Copyright (c) 1999-2018, by Zend Technologies
$ sudo a2enmod php7
Enabling module php7.
To activate the new configuration, you need to run:
service apache2 restart
$ sudo a2dismod php5
Module php5 disabled.
To activate the new configuration, you need to run:
service apache2 restart
$ sudo /etc/init.d/apache2 restart
All done! Good luck!
Well, then @risimini, why is your php5 still enabled?