When WordPress on an EC2 instance asks for FTP credentials to install plugins, it typically means that WordPress doesn’t have permission to write to the plugins directory directly. You can bypass the need for FTP credentials by modifying the permissions or updating the configuration file.
1. Bypass FTP by Modifying wp-config.php
- Connect to your EC2 instance via SSH.
- Open the
wp-config.php
file in your WordPress directory (usually located in/var/www/html
or another directory depending on your setup). - Add the following line to the
wp-config.php
file, ideally near the bottom:
define('FS_METHOD', 'direct');
Save and close the file. This line tells WordPress to use the direct file system method, allowing it to write directly to the file system without requiring FTP credentials.
2. Adjust Directory Permissions
If the above method doesn’t resolve the issue, you may need to adjust the permissions of your WordPress directories to allow write access.
Run the following commands to ensure WordPress can write to the appropriate directories:
sudo chown -R apache:apache /var/www/html sudo chmod -R 755 /var/www/html sudo find /var/www/html -type d -exec chmod 755 {} \; sudo find /var/www/html -type f -exec chmod 644 {} \;
Replace /var/www/html
with your WordPress directory path if it differs.
After making these changes, try installing the plugin again. WordPress should no longer prompt you for FTP credentials.