Content health: drafting stage
This chapter is not yet finished. To speed up the progress, help us fix it at GitHub.

PHP installation

Use the PHP installation wizard to get the installation instructions for your system.

Which version of PHP to use?

Make sure to use the latest stable version PHP 7.2. Versions on some online production servers can be few versions behind the latest PHP releases because of hosting policies and backwards compatibility. Don't let this stop you from using the latest PHP with all its shiny new features.

PHP installation

You can download and use PHP binaries and sources for Windows and other systems from the official site. Building PHP from source on your own has its benefits in that you can configure your build according to your specific requirements. Refer to the PHP manual for learning how to build PHP from source.

PHP has a useful built-in web server for local development. Inside your project folder you can run it from the command line:

php -S localhost:8000

Visit http://localhost:8000/index.php in your browser to access it.

To successfully develop and run PHP applications you will eventually need a more advanced web server such as Apache or Nginx, a database such as MySQL or MariaDB, and other useful tools such as Xdebug, Adminer, phpMyAdmin, etc. Whether you're using Windows, OS X or Linux, you can simplify installation by using one of these all-in-one packages:

Windows installation

Aside from the above, on Windows, you can also use one of the following useful all-in-one packages:

OS X

By default, OS X includes a slightly outdated PHP. To install and use the latest PHP on OS X, aside from by using one of the aforementioned packages, you can also use one of the following solutions:

Linux installation

Linux and Unix based operating systems are a bit more complex and diverse. Learning to use these environments is recommended for developers. After all, there's a high chance that your web application will be hosted on such servers. PHP installation can be done with package managers, that distribution uses (apt-get, pacman, zypper or yum, with its successor dnf).

A simplified example of apt usage for Debian based distributions (Debian, Ubuntu...):

sudo apt-get install php

and yum (or newer dnf) for Fedora based distributions (Fedora, RHEL, CentOS...):

sudo dnf install php

Keep in mind that there are many other packages such as php-curl, lamp-server, php-mysql and others, to be explored with your distribution.

Third-party Linux repositories

Most of the time the default PHP version provided by the distribution will be a few versions behind the latest stable release from PHP.net. This is where some useful third-party repositories can come in handy:

Virtualization and containers

A more advanced and recommended way of professional PHP development nowadays is by using virtualization software such as Virtual Box, Vagrant, and Docker. These help you reduce friction between development and production environments. With virtual environments, you can make your development (software versions, configuration...) the same as what your production is.

Docker

Docker chapter includes more information how to use PHP with Docker.

After you successfully install PHP, proceed to the PHP editors and IDEs chapter.



Found a typo? Something wrong with this content?

Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all contributors.