Wednesday, June 28, 2017

Linux: Install PHP7 on Debian 9 Stretch

One of the improvements on Debian 9 Stretch , PHP7 is now on the default apt source list. So it is now easier to install PHP7 and PHP7 modules on Debian 9 Stretch. Because in earlier Debian like Debian 8.8 Jessie, you need to add this dotdeb repository in order to install PHP7 which is pain in the ass. In this tutorial, we are going to install PHP7 and PHP7 modules on Debian 9 Stretch so that we can create PHP7 web application immediately.  

1. First, we need to configure our apt source list. APT source list is one of the important thing to see so that we can start installing packages on Debian 9 Stretch. Take note that I'm using vi on editing files but you can use other editing tools like nano, pico etc.  

vi /etc/apt/source.list



2. Skip this step if you already have this lines of code. This six lines of code below are the main APT repository on Debian 9. But if you want to install packages outside these repository, you can add repositories at the end of the line. After typing all the repositories, you can now save it. 


deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main
deb http://deb.debian.org/debian/ stretch-updates main non-free contrib
deb-src http://deb.debian.org/debian/ stretch-updates main non-free contrib
deb http://ftp.debian.org/debian/ stretch main non-free contrib
deb-src http://deb.debian.org/debian/ stretch main non-free contrib





3. Install PHP7.0 on Debian 9 Stretch. We will also install PHP7.0 modules like fpm, mysql, cli, mcrypt. But there are also many modules like pgsql, json, mbstring etc that you need to look at. But for now, we just install the main PHP7 modules. 


apt install php7.0 php7.0-fpm php7.0-mysql php7.0-cli php7.0-mcrypt




4. Check PHP7.0 on your system. By using the command php -version, you will be able to see the version of your php installed in your system. If you dont see anything, feel free to ask questions for this topic below. Thanks for viewing. :)


php -version


2 comments:

  1. Thanks for providing a clear concise list of main modules.
    This helped me fix my LAMP server after upgrading from Debian 6 to Debian 9 and having lots of issues; the finishing touches to restoration are almost complete, thank you!

    ReplyDelete