Last updated August 7, 2015. Created on September 13, 2012.
Edited by moshe weitzman, hussainweb, ericxb, David_Rothstein. Log in to edit this page.

Below you will find some additional notes regarding the PHP requirements for Drupal. Individual modules may have specific requirements and configurations needed; please double check module documentation as well. Within the Drupal interface, it is highly recommended that caching be enabled under admin/config/development/performance. This will help increase the performance of your Drupal installation and the end user experience. For more details see Caching to improve performance.

On this page:

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.

File and Folder Permissions

Drupal and PHP should have read and write access to the /sites/default/files directory. This area is used to store cached files (compressed CSS and JavaScript) and any file uploads through the Drupal interface. The exact permissions of this directory depend on how your PHP installation is configured. Generally speaking, read-write-execute for all, nobody user, (777) is not recommended as a security risk. PHP can be run under as the specific user account on the server using suPHP rather than a generic user (www) or nobody.

PHP Configuration Settings

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

  • error_reporting set to E_ALL & ~E_NOTICE. Work is ongoing to change this to E_ALL for Drupal 6 and Drupal 7.
  • safe_mode: off. Safe mode may interfere with file and image uploads. This is applicable for only for PHP version's below 5.3.0, as of PHP 5.4.0 Safe Mode has been removed
  • Tokenizer functions require the tokenizer extension to be enabled. (Read more #357970: Undefined function token_get_all)

Setting: session.cache_limiter = nocache

Setting: session.auto_start = 0

Setting: expose_php = off
Reason: Shows current PHP version in all header requests, security disclosure, see here
Example: X-Powered-By: PHP/5.3.8

Setting: allow_url_fopen = off
Reason: This is a security issue: see here

Setting: magic_quotes_gpc = off
Reason: Forces quotes in variables - This feature has been deprecated as of PHP 5.3.0 and removed as of PHP 5.4.0.

Setting: register_globals = off
Reason: Security issue - having this enabled subjects PHP variables to input from any source:
This feature has been deprecated as of PHP 5.3.0 and removed as of PHP 5.4.0.

Setting: display_errors = Off
Reason: Hides errors output to display (website) we want to send to log file instead.

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.
  • Drupal 8 core requires 64MB.

Note that Drupal 8 uses extensive lazy loading of code and data. Slight differences from page to page can produce huge differences in memory usage. Check memory usage for each type of page and view. The administration pages should produce the worst cases.

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 could require more memory. Typically 128 MB or 256 MB are found in production systems. 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.)

Extensions

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. GD is a required extension in Drupal 7 and later. 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.

JSON

Drupal 7 and 8 require PHP compiled with JSON. JSON support is normally compiled as part of PHP core, but in case you're getting errors like PHP Fatal error:  Call to undefined function Drupal\\Component\\Serialization\\json_encode() in ... core/lib/Drupal/Component/Serialization/Json.php try adding the JSON extension.

APC

Recent versions of APC (apparently since 3.1.6) set 'Enable internal debugging in APC' as the default. This generates large numbers of PHP messages that can make diagnosing other problems more difficult. This option can be disabled during installation by explicitly entering no to the prompt - hitting 'enter' will enable the option in spite of the wording of the prompt.

Also see Drupal 7-specific information relating to APC.

ssh extension

The ssh PECL extension is an optional add-on to your PHP setup. While it is not required for normal Drupal function, when absent, both the Add new module and Add new theme links in your drupal's administration will fail with the admittedly uninformative message:"Your server does not support installing modules and themes from this interface. "

Twig C extension

Drupal 8 now uses Twig as the default PHP templating engine. While Twig is included as part of Drupal core, portions can optionally be compiled and included as a PHP extension to improve performance rendering templates. The status report on your site has a section which will indicate whether the Twig C extension has been loaded. The source code for the Twig C extension can be found in your installation within [drupal root]/core/vendor/twig/twig/ext/twig. If you want to install the extension, follow these instructions.

Other

.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 All in the main Apache configuration (usually httpd.conf) is enabled
  • 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.

Other interfaces

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

xdebug

If using xdebug:

Setting: xdebug.show_exception_trace = 0
Reason: Could cause Drupal's installer to crash

If using xdebug with Drupal 8:

Setting: xdebug.collect_params = ?
Reason: Setting xdebug.collect_params too high will prevent Drupal 8 from installing and working properly.

Setting: xdebug.max_nesting_level = 256
Reason: Using the default max_nesting_level of 100 (in xdebug versions < 2.3) causes some pages to crash.

Drupal specific version notes on PHP requirements

All versions

PHP version Drupal 6 Drupal 7 Drupal 8
4.4 yes, no support no no
5.0 yes no no
5.2 yes 5.2.5+ (*) no
5.3 core ok; some contrib modules and themes may have problems yes no
5.4 core ok; some contrib modules and themes may have problems yes (minimum recommended) no
5.5 core ok; some contrib modules and themes may have problems yes 5.5.9+
5.6 no yes yes
7 no in progress in progress

(*) 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.

It is often possible to update to a newer version of PHP than ships with your Linux distribution. For RHEL, we recommend http://iuscommunity.org/Repos, and for Debian, http://www.dotdeb.org/.

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.5.9 or later, with the CURL extension. However it is recommended to use 5.6.5 or higher. PHP 5.6 is the latest minor release of PHP and therefore offers extra performance and security. Since 5.6.5 (and 5.5.21) PHP also provides built-in SQL injection protection for mysql databases. PHP 7 is your best bet once released, as it has much improved performance.
  • If your curl library is version 7.35 (the default on some ubuntu distibutions), there is a bug that could intermittently affect connectivity with other sites.
  • Drupal 8 can no longer be installed on hosts with the 'magic_quotes_gpc', 'magic_quotes_runtime', or 'safe_mode' PHP ini settings turned on; these settings are deprecated in PHP 5.3 and have no effect anymore in PHP 5.4 and higher.
  • PHP Data Objects (PDO) must be activated for Drupal 8 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 8 and cannot be used.
  • The Drupal 8 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.
  • Drupal 8 may require the time parameter (max_execution_time) to be at least 30 seconds.
  • If using the APC opcode cache with Drupal 8, APC 3.1.13 or greater is required. PHP 5.5 has the Zend opcode cache built in.
  • php5-ctype is required.
  • The following PHP requirements list is from Drupal 8 beta 12:
    <?php
      $required_extensions
    = array(
       
    'date',
       
    'dom',
       
    'filter',
       
    'gd',
       
    'hash',
       
    'json',
       
    'pcre',
       
    'pdo',
       
    'session',
       
    'SimpleXML',
       
    'SPL',
       
    'tokenizer',
       
    'xml',
      );
    ?>

Drupal 7

  • Drupal 7 requires PHP 5.2.5 or higher (or PHP 5.2.4 with backported security patches, such as the version included with Ubuntu 8.04). PHP 5.4 or higher is recommended.
  • 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.
  • The 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.
  • Drupal 7 may require the time parameter (max_execution_time) to be at least 30 seconds.
  • APC installation guides sometimes recommend setting apc.include_once_override=1. Although this setting does not appear to affect Drupal 6, it causes Drupal 7 to fail (white screen, error 500) as reported in Do not enable apc.include_once_override.
  • The following PHP extensions are required for Drupal 7:
    <?php
      $required_extensions
    = array(
       
    'date',
       
    'dom',
       
    'filter',
       
    'gd',
       
    'hash',
       
    'json',
       
    'pcre',
       
    'pdo',
       
    'session',
       
    'SimpleXML',
       
    'SPL',
       
    'xml',
      );
    ?>

Drupal 6

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

ryoken’s picture

It would be helpful (especially those planning to run Drupal on a virtual or dedicated server), to have a comprehensive list/table of required (and optional) PHP extensions. Default PHP extensions (that are automatically enabled) can differ between different operating systems and different PHP versions.

For example, Zend Framework's PHP requirements page is clear and concise, breaking down each PHP extension with a dependency description:

http://framework.zend.com/manual/1.12/en/requirements.introduction.html

Therefore, those planning to run Drupal on their system can do a quick "php -m" to determine if there are any gaps to meet Drupal's PHP requirements.

tinaunglin’s picture

In this documentation [ or guide ] , the links to the recommending php.ini settings are broken. They don't work anymore and show 404 error.

Thanks

I am a Web Developer . I love Drupal and its community.

mbrett5062’s picture

It seems Drupal 8 now requires the following extension enabled also.

php_fileinfo.dll

I never got this requirement error before Drupal 8 Alpha 14

Editing the page information for Drupal 8 now.

heters’s picture

It's right , Drupal 8 Alpha 14 require the php_fileinfo extension, thank you!!

AFowle’s picture

In openSuse 13.1, D8.0.0-alpha14 installation fails with WSOD without this. The minimum requirements to prevent WSOD are

apache2-mod_php5
php5
php5-ctype (added to main text)
php5-json (get nasty text interface rather than WSOD without it)
php5-mysql
php5-pdo

Probably need more than this at later stages.

AFowle’s picture

These are listed as required by the requirements checking page. These are mentioned in the main text, but not very clearly. I have NOT adjusted page as I don't understand the current entries.

peterx’s picture

The PHP requirements list in Drupal 8 alpha 15:
$required_extensions = array(
'date',
'dom',
'fileinfo',
'filter',
'gd',
'hash',
'json',
'pcre',
'pdo',
'session',
'SimpleXML',
'SPL',
'tokenizer',
'xml',
);