How To Fix: FastCGI sent in stderr – PHP message: PHP Warning: move_uploaded_file

PHP Warning: move_uploaded_file is a typical web server error with Nginx and appears when we want to upload a file to the server. Most of the time, when we have to upload certificates or other files that do not belong to “Media”, we do not see the error in the interface of adminCMS registration.

In a more concrete form, the error “PHP Warning: move_uploaded_file” we find it in error.log as:

FastCGI sent in stderr: "PHP message: PHP Warning:  move_uploaded_file(/srv/www/domain.test/public/file.file): failed to open stream: Permission denied in /srv/www/domain.test/public/script.php on line 748 PHP message: PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpqAVtWy'

Why the error occurs PHP Warning: move_uploaded_file and how we solve it

As I said above, the error occurs when we try to upload files to the web server.

"FastCGI sent in stderr”Is typical for servers that have PHP-FPM and Nginx as web software. So the problem is somewhere in the relationship of the script through which the files are uploaded.

"move_uploaded_file(): Unable to move”Tells us very clearly that those files cannot be uploaded and moved to another folder on the web server by the script that performs the operation.

Resolve this error PHP it is solved very simply, setting the correct permissions on the server, both for the execution script, to which the most probable user: nginx did not have access, and for the destination folder.

If the website files do not belong to a user, as it is on cPanel, VestaCP or other hosting management platforms, then almost certainly the solution is to give the nginx user access to the upload folder and the script.

For the above code example, we will execute the following command in SSH:

chown -R nginx:nginx /srv/www/domain.test/public/
chmod g+w file.file

We resume uploading and everything should work without error move_uploaded_file(): Unable to move.

If you still encounter problems, it can be solved in the comments of this tutorial.

Passionate about technology, I like to test and write tutorials about operating systems macOS, Linux, Windows, about WordPress, WooCommerce and configure LEMP web servers (Linux, NGINX, MySQL and PHP). I write on StealthSettings.com since 2006, and a few years later I started writing on iHowTo.Tips tutorials and news about devices in the ecosystem Apple: iPhone, iPad, Apple Watch, HomePod, iMac, MacBook, AirPods and accessories.

Leave a Comment