When performing WordPress updates, some installations prompt for FTP information. This request for FTP information is because WordPress cannot write the updates to files on the server through PHP and therefore requests FTP login information to attempt to write files via FTP instead of PHP.
But, if you do not have FTP access, or do not use FTP for transferring files to sites because you are using something like SCP, RSYNC or GIT hooks to send files to a live server, then what do you do?
There are multiple ways to set how WordPress updates from the wp-config.php file, listed on the WordPress.org website.
But that can cause security problems. A temporary way to allow updates through PHP is to run the chown command, which changes the user of the files that need to be updated. Here are the steps to make the temporary change:
- Find the PHP user by running the following code on the server:
< ?php echo exec('whoami'); ?>
- After you have the user name that PHP runs under, execute the chown command on the server to the directory that WordPress is installed under:
$ chown -R username directory
- Now that the user name was changed to match the PHP user on all the files in the WordPress directory you can perform updates in the WordPress admin without receiving the FTP prompt.
Your WordPress site shouldn’t suffer any downtime or disruptions during the user switch, as typical permissions on webserver files allow the group to read the files. - After you have made the updates, execute the same command, but with the older username
$ chown -R oldusername directory
You now are back to normal with the new updates.
If you switch the username and do not switch back to the original username. you may run into issues with other services, but most likely not the web site delivery.