Well : I am using WordPress on my server which only uses SFTP using an SSH key.
I did some more research and got aware that: WordPress will only prompts me for the FTP connection information, while trying to install plugins or a WordPress update. well i wonder why: it seems that it cannot write to /wp-content directly. At least it seems to be the point. I guess that this is the cause of the issue. Otherwise i guess that the web server would have write access to the necessary files, it will take care of the updates and installation automatically. This method does not require me to have FTP/SFTP or (even more) SSH access, but it does require me to have specific file permissions set up on your webserver.
the question is: how to do that: how to tell the Web-Server this - and how to set the specific file permissions set up on the webserver?
Which mehthods can be used here!?
in other words: how does the configuration file looks - if i add all the necessary directives to the file?
Look forward to any and all help.
cheers
update: i did some further research:
well i think its pretty obvious that WordPress asks for FTP credentials when it can't directly write to files. i guess that there are some things necessry in order to enable updates via the WordPress admin dashboard without FTP credentials:
i think that we need to ensure that the web server has the correct permissions to write to the necessary directories.
and i think that there some methods exist that help to fix this Issue:
1. i need to correct File Permissions
set the correct ownership and permissions for the WordPress files.
A. Set Ownership Correctly
- WordPress should be owned by the same user our web server (usually
www-data
for Apache/Nginx on Ubuntu/Debian, orapache
on CentOS).
sh
sudo chown -R www-data:www-data /var/www/html/wordpress
Adjust the path (/var/www/html/wordpress
) to your actual WordPress installation.
B. Set Correct Permissions
- Directories should be 755 (read, write, execute for owner; read and execute for others).
- Files should be 644 (read and write for owner, read-only for others).
sh
find /var/www/html/wordpress -type d -exec chmod 755 {} \;
find /var/www/html/wordpress -type f -exec chmod 644 {} \;
This ensures that WordPress can write to wp-content
without needing FTP.
2. Force Direct File System Method
If permissions alone don't solve it, you can explicitly tell WordPress to use the direct file system method. Add this to your wp-config.php
:
define('FS_METHOD', 'direct');
Place it above the /* That's all, stop editing! Happy blogging. */
line.
3. Disable Security Restrictions (Only If Necessary)
Some security settings (e.g., open_basedir
) in php.ini
may block file writes. Check your PHP configuration:
php -i | grep open_basedir
If open_basedir
is set, consider disabling it for WordPress.
4. Ensure Apache/Nginx Has Write Access
If you're running Apache or Nginx, make sure their process user (e.g., www-data
or apache
) has write permissions. You can check the user with:
ps aux | grep apache
ps aux | grep nginx
If the ownership does not match, adjust it as described in step 1.
Final Check
Once you've done the above, try updating WordPress or installing a plugin. If it still asks for FTP, restart the web server:
sh
sudo systemctl restart apache2 # for Apache
sudo systemctl restart nginx # for Nginx
Top comments (0)