Always_populate_raw_post_data setting in PHP 5.6 & Magento 2.0

Does Magento 2 throw an error about always_populate_raw_post_data being set to 0? And are you having problems installing or updating Magento with PHP 5.6 and PHP 7? Then read on, because here is how to fix upgrades to Magento 2.0 in PHP 5.6 and higher (PHP 7).

PHP always_populate_raw_post_data ($HTTP_RAW_POST_DATA) & Magento 2.0 #

Magento 2.0 requires PHP’s always_populate_raw_post_data to be disabled, or set to -1 in your php.ini file. Since PHP 5.6, the use of $HTTP_RAW_POST_DATA is deprecated and will be removed in PHP 7.0. However, in PHP 5.6, this setting is commented out, making it equal to 0, not -1.

This causes errors when you try to install, or update to, Magento 2.0 using PHP 5.6 or PHP 7.

The PHP always_populate_raw_post_data setting will let PHP always populate the $HTTP_RAW_POST_DATA containing the raw POST data, if set to true (1). Otherwise, the variable is populated only when the MIME type of the data is unrecognized.

Pro tip: learn how to validate MIME types with PHP Fileinfo!

Magento 2.0 PHP Settings Check #

And this is where Magento goes wrong… Well, in my opinion Magento goes wrong by quitting the installer. The error should only be thrown when both display_errors and display_startup_errors are enabled in your PHP configuration. On my production servers, they’re disabled.

Unfortunately Magento 2.0 PHP settings check still complains, and throws the following error message:

Your PHP Version is 5.6.15, but always_populate_raw_post_data = 0. $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. This will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.

PHP Settings Check, the quick fix for Magento #

Here is how you can quickly fix Magento’s always_populate_raw_post_data = 0 error with PHP 5.6/7.0:

  • upload a user defined ini-file, or a .user.ini file, to your website’s root folder. It has to contain the following setting:
always_populate_raw_post_data = -1

While going through your PHP config, fix & set correct values for curl.cainfo and openssl.cafile too. Stop turning off CURLOPT_SSL_VERIFYPEER (or sslverify = false for wp_remote_get() in WordPress).

This may interest you:   PHP 5.6 default_charset change may break HTML output

This will set the always_populate_raw_post_data value to how it is supposed to be: -1. For your Magento website only. The directive is a PHP_INI_PERDIR and PHP_INI_ALL setting, meaning you can set it anywhere. If you are a server administrator, make the change to your php.ini file; automatically populating $HTTP_RAW_POST_DATA is removed in PHP 7.0.0 and deprecated in PHP 5.6.

If set to TRUE, PHP will always populate the $HTTP_RAW_POST_DATA containing the raw POST data. Otherwise, the variable is populated only when the MIME type of the data is unrecognised.

The preferred method for accessing raw POST data is php://input, and $HTTP_RAW_POST_DATA is deprecated in PHP 5.6.0 onwards. Setting always_populate_raw_post_data to -1 will opt into the new behaviour that will be implemented in a future version of PHP, in which $HTTP_RAW_POST_DATA is never defined.

Regardless of the setting, $HTTP_RAW_POST_DATA is not available with enctype=”multipart/form-data”.


Show your support


If you want to step in to help me cover the costs for running this website, that would be awesome. Just use this link to donate a cup of coffee ($5 USD for example). And please share the love and help others make use of this website. Thank you very much!


About the Author Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, websites & optimization.

follow me on:

Leave a Reply

14 Comments on "Always_populate_raw_post_data setting in PHP 5.6 & Magento 2.0"

avatar
  Subscribe  
newest oldest most voted
Notify of
Angela
Guest

Hi, I’m a newbie trying to install Magento on MAMP. No coding skills, what a shame…so I’ve come across this error;
PHP Settings Check
Need Help?
PHP Documentation
Your PHP Version is 5.6.10, but always_populate_raw_post_data = 0. $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. This will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.

I understand php.ini must be changed, so I’d like to know what application should be used to do so.
Any help would be highly appreciated:-)))

max
Guest

You should be able to change the php.ini from /Applications/MAMP/conf/php5.6.1/php.ini

Angela
Guest

Yes I can find the php.ini file but I can’t change it, cannot find the right application for this purpose….maybe creating a new php.ini file and replacing the existing one through Notepad could help?

danieliwao
Guest

Hey I updated the php.ini file on my local host under MAMP but I’m still running into the same error. Any other advice?

berteldk
Guest

Nothing happens when i change the .ini file in my mamp folder. I assume it must be in the folder called 5.6.10/php.ini – right?

jaf kman
Guest

nothing happens at my server either…

Your PHP Version is 5.6.18-1+deb.sury.org~trusty+1, but always_populate_raw_post_data = 0. $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. This will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.

have changed the php.ini file with the property always_populate_raw_post_data = -1 and restarted apache2. I just keep getting the error message.

Help anyone?

jaf kman
Guest

Fixed the Magento2 always_populate_raw_post_data -1 issue as the php.ini file configuration is not working:

In your apache2 config file /etc/apache2/sites-available/000-default.conf
add this: php_value always_populate_raw_post_data -1

mine looks like this:

AllowOverride All
php_value always_populate_raw_post_data -1

shahzad
Guest

.user.ini file Great it worked. thanks

Ronny
Guest

Hi everyone,
I am a newbie and don’t have no experience using magento.

When I look in my php.ini file I find this
“; Always populate the $HTTP_RAW_POST_DATA variable. PHP’s default behavior is
; to disable this feature. If post reading is disabled through
; enable_post_data_reading, $HTTP_RAW_POST_DATA is *NOT* populated.
; http://php.net/always-populate-raw-post-data
;always_populate_raw_post_data = on”

Where do I change “always_populate_raw_post_data to -1” ?
can anybody help me with that?

sakamotz
Guest

I had same trouble.

In my case there is a .php.ini.swp file , I was solved Once you remove it.

> rm /etc/php5/apache2/.php.ini.swp
> /etc/init.d/apache2 restart

Ronnyman
Guest

I Installed WAMP and Magento 2 on Win Server 2012 R2 and fixed this error by uncommenting the php_value always_populate_raw_post_data -1 located in C–Wamp64—bin—php—php5.6.16—php.ini