Course lectures : 1 of 1

Error: $HTTP_RAW_POST_DATA is deprecated

Last updated: 10th September 2015

$http_raw_post_data errornginx errornginx server

Recently I came across a problem when dealing with nginx server purchased from DigitalOcean.

Every time I tried to upload an image I was getting the nasty error saying:

Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version.
To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead.

Interestingly enough, I've run a search on all my files and I couldn't find any that would use the mentioned $HTTP_RAW_POST_DATA.

Nevertheless, I've checked the PHP documentation for always_populate_raw_post_data and alongside many things it says the following:

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.

Now, my droplet with DigitalOcean runs Ubuntu with nginx so the first thing I had to do is to figure out where my php.ini file is located, which contains the entry for always_populate_raw_post_data.

This was pretty easy, by simply checking the nginx documentation and in my case appeared to be under the /etc/nginx directory.

Now, to make changes to this file, you have to run session as root user so make sure you have root password and switch to root user by using:

su - root

Then type your password.

Now check, which line in the php.ini file contains the always_populate_raw_post_data:

grep -n 'always_populate_raw_post_data' /etc/nginx/php.ini

If you're using Homestead the path to php.ini is


or if you're using PHP7 it might be under:


In my case the answer was:

704:;always_populate_raw_post_data = -1

which indicates that it's on line 704 and it has the right value (-1) associated with it, but it is commented ;.
Using vi editor, open the file on that line:

vi +704 /etc/php5/fpm/php.ini

and remove the semi colon ; to uncomment it, then to save your changes and exit the editor simply type:


and hit return on your keyboard.

Last thing you need to do is to reboot the server by either using the GUI (Graphical User Interface) or shell command (you have to be logged in as root to be able to execute it):


Once server is back up the error should be gone.


If you'd like to include code example please wrap your code within <pre><code> tags.

function fullName(firstName, lastName)
    return firstName + ' ' + lastName;