Last updated May 21, 2013. Created by mitchell on September 13, 2012.
Edited by bailey86, matt2000, chx, mojzis. Log in to edit this page.

PHP is a widely-used general-purpose scripting language that is especially suited for Web development.

Below you find some additional notes regarding the PHP requirements for Drupal.

PHP from different sources

Drupal is designed to work with PHP as distributed on php.net. Every effort is made to make it work with PHP versions from other sources but this is only done on a best effort basis. In particular, suhosin is known to break certain features and some operating systems move core components into other packages.

Database extensions

The PHP extension for connecting to your chosen database must be installed and enabled. Drupal's currently supported database connectors are: mysql (the original MySQL extension), mysqli (an improved connector for newer MySQL installations), and pgsql (for PostgreSQL). Note: PHP 5.x no longer enables the mysql extension by default. Please read the links above for installing and enabling your chosen connector. Additionally, Drupal 6.x does not provide the option to select the mysql connector if mysqli is enabled in your PHP configuration.

XML extension

PHP XML extension (for Blog API, Drupal, and Ping modules). This extension is enabled by default in a standard PHP installation; the Windows version of PHP has built-in support for this extension. Enabling the XML extension also enables PHP DOM. DOM is now a systems requirement.

Image library

An image library for PHP such as the GD library is needed for image manipulation (resizing user pictures, image and imagecache modules). GD is included with PHP 4.3 and higher and usually enabled by default. ImageMagick is also supported for basic image manipulations in Drupal core but there is much less support from contributed modules.
If you have administrator rights on a Debian/Ubuntu server, and GD is not already available (see your phpinfo) it can usually be installed by running the following command:
sudo apt-get install php5-gd
or on Redhat/Centos:
sudo yum install php-gd
See the ImageMagick install instructions for your platform if you want that.

Memory requirements

PHP memory requirements can vary significantly depending on the modules in use on your site. Drupal 6 core requires PHP's memory_limit to be at least 16MB. Drupal 7 core requires 32MB. Warning messages will be shown if the PHP configuration does not meet these requirements. However, while these values may be sufficient for a default Drupal installation, a production site with a number of commonly used modules enabled (CCK, Views etc.) could require 64 MB or more. Some installations may require much more, especially with media-rich implementations. If you are using a hosting service it is important to verify that your host can provide sufficient memory for the set of modules you are deploying or may deploy in the future. (See the Increase PHP memory limit page in the Troubleshooting FAQ for additional information on modifying the PHP memory limit.)

.htaccess settings

Some of the memory settings are contained in the default .htaccess file that ships with Drupal, so you shouldn't need to set them explicitly. Note, however, that setting PHP configuration options from .htaccess only works under the following conditions:

  • With Apache (or a compatible web server)
  • If the .htaccess file is actually read, i.e. AllowOverride is not None
  • If PHP is installed as an Apache module

In some shared hosting environments, access to these settings is restricted. If you cannot make these changes yourself, please ask your hosting provider to adjust them for you.

PHP needs the following configuration directives for Drupal to work (only directives that differ from the default php.ini-dist / php.ini-recommended):

Other interfaces

See the PHP manual for how to change configuration settings for other interfaces to PHP.

xdebug

If using xdebug, ensure that the xdebug.show_exception_trace value is set to 0, or this could cause Drupal's installer to crash.

Version specific notes on PHP requirements

All versions

On Debian libapache2-mod-php5filter may get installed in preference to libapache2-mod-php5 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=709027). Unfortunately the libapache2-mod-php5filter package has a bug which breaks Drupal - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=709023

So, make sure you specify to use the libapache2-mod-php5 package instead.

Drupal 8

Drupal 8 requires version PHP 5.3.10 or later, with the CURL extension.

Drupal 8 can no longer be installed on hosts with the 'magic_quotes_gpc' or 'magic_quotes_runtime' PHP ini settings turned on; these setting are deprecated in PHP 5.3 and have no effect anymore in PHP 5.4.

PHP 5.3.10 is required, for RHEL, we recommend http://iuscommunity.org/Repos and for Debian, http://www.dotdeb.org/ .

Drupal 7

  • The standard PHP extensions (enabled by default) Hash and JSON are required by Drupal 7.
  • Drupal 7 Update manager can install/update modules and themes via SSH if the required libraries have been installed on the server. If you have administrator rights on a Debian/Ubuntu server, and SSH is not already available (see your phpinfo) it can usually be installed by executing:
    apt-get install libssh2-php.
  • PHP Data Objects (PDO) must be activated for Drupal 7 to install and run correctly. Look in your php.ini. Uncomment (remove the leading semicolon) at line extension=php_pdo.dll, extension=php_pdo_mysql.dll. In Linux, these would be extension=pdo.so and extension=pdo_mysql.so. Some Linux distributions may have these extensions by default in files found in the conf.d folder (Ubuntu 12.04: /etc/php5/conf.d has pdo.ini and pdo_mysql.ini). If these lines are not there, you will need to add them. The PECL version of PDO is not compatible with Drupal 7 and cannot be used.
  • Drupal 7 may require the time parameter (max_execution_time) to be at least 30 seconds.

Drupal 7: PHP 5.2.5* or higher (5.3 recommended)

*For Drupal 7, versions of PHP 5.2.4 that include backported security patches also meet the requirements. The PHP version included with Ubuntu 8.04 is the most common example of this.

See the phpinfo() page on Drupal.org to learn how to use phpinfo to get the details of your system. For example, phpinfo will tell you if you have a database already installed and what versions of PHP, MySQL, etc. your system is running. Phpinfo will also tell you what PHP variables are set as well as many other helpful things.

Drupal 6

Although PHP 5.3 is supported by Drupal 6, some contributed modules may not be compatible with PHP 5.3, and some PHP 5.3 configurations still show warnings with Drupal 6.14. Work is ongoing to resolve the latter in #360605: PHP 5.3 Compatibility. Most Drupal 6 contributed modules throw E_STRICT errors on PHP 5.3 and many are practically unusuable on 5.4.

Drupal 5

Drupal 5 requires PHP 4.4.0 or higher. PHP 5.2 is recommended. Drupal 5.x does not support PHP 5.3

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 5.x, Drupal 6.x, Drupal 7.x, Drupal 8.x
Audience
Site administrators
Keywords
php, requirements
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here