If you recently installed a fresh copy of WordPress on your server and tried to install a new theme or a new plugin you might saw the following message:
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.
WordPress has a setting called FS_METHOD. FS method defines the file system method for WordPress. The value for FS_METHOD can be any of the following options:
Usually, when there is a permission issue you will get a different message:
Installation failed: Could not create directory.
In this scenario, you need to adjust the file system permissions on your server. For doing this step you need to have SSH access to the server.
- First, connect to your server using SSH command.
- Then, you need to figure out what user Apache server is running as. Run the following command to get the apache user:
ps aux | egrep '(apache|httpd)'
- In this example, my Apache is running as www-data
- Next, run the following command (Replace /var/www/html with your site root directory. Replace www-data with your Apache user):
sudo chown -R www-data /var/www/html
Chown command will change the owner of the root directory and will fix the permission issue. Now PHP(WordPress) should be able to create a directory. Now can try to install your plugin/theme.