How to install PHP 7
Below, we explain how to install PHP 7. If you think it is a complex procedure, we have to disappoint you – installing PHP 7.0.0 is a piece of cake. Our guide is divided into several sections each of which describes PHP 7 installation depending on a specific platform. Additionally, you will find links to other Firebear’s materials about the latest version of the coding language in the end of the article.
Table of contents
Beware of PHP 5.X!!!
Chances are, you already have PHP 5.x running on your machine. The previous version of the language causes conflicts and leads to errors, so you must completely remove it from the system before going any further. Only then, it is possible to install PHP 7.0.0.
For instance, if you are a loyal Ubuntu enthusiast, uninstalling PHP 5 is a breeze. Simply run the following command
1 |
sudo apt-get purge php5-* |
How to install PHP 7
The following material describes how to install PHP 7 on Ubuntu, Debian, CentOS, RHEL, Mac OS X, and Windows. Appropriate versions of the software are listed below. In addition, there are links to PHP 7 packages for each platform.
Ubuntu
You can easily install PHP 7 on the following Ubuntu versions:
- 14.04
- 15.04
- 15.10
To install the software, use this package:
Now, when you know what package is necessary, it’s time to provide you with the appropriate command. To install PHP 7 on Ubuntu, run the following code:
1 2 3 |
sudo add-apt-repository ppa:ondrej/php-7.0 sudo apt-get update sudo apt-get install php7.0 |
Debian
You can install PHP 7 on the following Debian versions:
- 6
- 7
- 8
To install the software, use this package:
Now, when you know about the necessary PHP 7 package, add the following lines to the /etc/apt/sources.list file:
1 2 |
deb http://packages.dotdeb.org <distribution> all deb-src http://packages.dotdeb.org <distribution> all |
Where <distribution> should be replaced with wheezy, squeeze, or jessie:
The next step requires adding the GPG key:
1 2 |
wget https://www.dotdeb.org/dotdeb.gpg sudo apt-key add dotdeb.gpg |
Now, you can install PHP 7 on Debian via the following commands:
1 2 |
sudo apt-get update sudo apt-get install php7.0 |
CentOS / RHEL
PHP 7 can be installed on CentOS and RHEL as well. The appropriate repository can be downloaded here:
By running the following code, you will install PHP 7 on CentOS/RHEL 7.x:
1 2 3 |
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php70w |
CentOS/RHEL 6.x PHP 7 installation is available via:
1 2 |
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm yum install php70w |
Mac OS X
PHP 7 can be installed on Mac OS X from 10.6 to 10.11 with the aid of
1 2 3 4 |
brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew install php70 |
Alternatively, you can rely on
1 |
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0 |
Windows
Windows users should look for the appropriate PHP 7 distributions here:
Other PHP 7 materials:
- The Best PHP 7 Books to Read
- How to Get Ready for PHP 7
- Zend Framework 3
- PHP 7 vs HHVM
- The Best PHP 7 Tutorials and Tools to Start With