HOME >> How To Wordpress >>

WordPress Tips: In a Minute, Stop WordPress Ask FTP / SSH Credentials To Upgrade or Delete or Add Plugins or Theme or Core Update

Posted on date Dec-17-2016 · by author  · comments Leave a Comment 

I was replied a wordpress user’s question, but I think my answer is not full correctly, so I’d like add more detailed reply in here, the question of the user is when he try to upgrade his wordpress, in wordpress dashboard,  it saying: ” The login credentials for FTP to update WP using FTP.Hostname, FTP Username, FTP Password“.

I am not tech literate beyond bare basics, I have used WP MultiSites for years online. No experience with servers ever and some minor dabbles in the files.

I don’t know:
The login credentials for FTP to update WP using FTP.
Hostname, FTP Username, FTP Password

I have done this local install solely to learn WP – not for developement or staging. I appreciate any input and direction to easy to comprehend sources of information. I have not had success with the WP Codex finding or using info from it in general.

 

Below is what I was replied:

I working on Linux OS too, I guess if you are use default install, the folder will be /var/www/html ? Also maybe your apache user:group is “apache:apache” ? If so maybe you can try:

chown -R apache:apache /var/www/html

Best Regards,
Tomas

But I think my reply is not full correctly, actually, there are many Linux OS, my answer is just helpful on a little Linux platform, so if we hope solve this problem on all Linux platform, it is not enough.

So, at first, let’s check back why this “The login credentials for FTP to update WP using FTP.Hostname, FTP Username, FTP Password” problem happen? Actually when you try to update / install / delete / upgrade your wordpress plugins or themes, or when you try to update core codes of wordpress, wordpress will call function get_filesystem_method() to check:

* Determines which method to use for reading, writing, modifying, or deleting
* files on the filesystem.
*
* The priority of the transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets
* (Via Sockets class, or `fsockopen()`). Valid values for these are: ‘direct’, ‘ssh2’,
* ‘ftpext’ or ‘ftpsockets’.

And then the function will try to call   create a temp file like this:

     $temp_file_name = $context . ‘temp-write-test-‘ . time();
$temp_handle = @fopen($temp_file_name, ‘w’);

If wordpress can not create the temp file, it will request you offer ftp or ssh accounts.

So the final problem is you can not create the temp file in your wordpress installation folder.

My answer is right, but not fully right, actually, in Centos, the default apache server user name and group name is apache, but in many Linux system, they using another apache username and groupname, for get the correctly apache server default username and groupname, we need find out it at:

gedit /etc/apache2/envvars

you will find it saying:

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

This is on ubuntu, so the apache user name and group name is www-data, and in ubuntu, if you want to aviod ” The login credentials for FTP to update WP using FTP.Hostname, FTP Username, FTP Password“, you need use this:

chown -R www-data:www-data /var/www/html

BY this method,  you can works well on other Linux OS and you will not have problem of “The login credentials for FTP to update WP using FTP.Hostname, FTP Username, FTP Password“. 🙂

Best Regards,

Tomas

 

 

 

 

 

 

 

Leave Your Comments

CAPTCHA
*