• Hi folks,

    I’m having a serious issue with WordPress and FTP which I’m really struggling to resolve. I would greatly appreciate some help, because this is a deal-breaker for me moving my hosting to Vultr from DigitalOcean (all of whose IP addresses are blacklisted).

    I have built a new WP install on a new machine (a VM from Vultr) and moved a site from a Digital Ocean machine. However, FTP within WP consistently fails, and I really can’t figure out why. It seems to be to do with the path WP is asking FTP to change to.

    Details:

    Both machines are running WP 6.0.3

    DO Machine:
    Ubuntu 16.04.7 LTS
    kernel: 4.4.0-210-generic
    vsftpd: version 3.0.3
    apache: 2.4.18 (Ubuntu)
    php: 7.0.33-0ubuntu0.16.04.16

    Vultr machine:
    Ubuntu 20.04.5 LTS
    kernel: 5.4.0-131-generic
    vsftpd: version 3.0.3
    apache: 2.4.41-4ubuntu3.12
    php: 7.4.3

    I’ve checked the vsftpd config on both machines, and it’s identical.

    wp-config.php has no clever stuff in it, but on the Vultr machine I have tried defining WP_CONTENT_DIR, WP_PLUGIN_DIR, FTP_BASE, FTP_CONTENT_DIR and FTP_PLUGIN_DIR in all combinations of absolute and relative paths and it’s made not a scrap of difference.

    Each machine is built from a script whereby the users have a path of /var/www/USER/www for their WP installation, and their $HOME in /etc/passwd is /var/www/USER. Apache is set up accordingly and works fine on both machines.

    Permissions are the usual WP permissions, and identical on each machine.

    What is happening is that all works as expected on the DO machine, but FTP fails on the Vultr machine in 2 ways. Firstly, if I try to update the language files if just hangs. If I try to delete a plugin I get the message “Unable to locate WordPress plugin directory.” If I try and add one, I get the message “Installation failed: Unable to locate WordPress plugin directory.”

    First off though, “normal” FTP via, say Filezilla, works perfectly well on each machine, as does command line FTP. Within FTP, users are chrooted to their home directory.

    Looking at the FTP logs gives the following story during an FTP update on WP:

    DO machine displays some CWD errors but gets on with it eventually. The Vultr machine just fails:

    DO log (edited for brevity). Firstly it tries the absolute path, then later it uses the correct path and all succeeds:

    CONNECT: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “220 Welcome to the XXX.convergent-ict.com FTP service.”
    FTP command: Client “127.0.0.1”, “USER ****”
    FTP response: Client “127.0.0.1”, “331 Please specify the password.”
    FTP command: Client “127.0.0.1”, “PASS <password>”
    OK LOGIN: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “230 Login successful.”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (127,0,0,1,156,153).”
    FTP command: Client “127.0.0.1”, “TYPE A”
    FTP response: Client “127.0.0.1”, “200 Switching to ASCII mode.”
    FTP command: Client “127.0.0.1”, “NLST /var/www/USER/www/wp-content”
    FTP response: Client “127.0.0.1”, “150 Here comes the directory listing.”
    FTP response: Client “127.0.0.1”, “226 Transfer done (but failed to open directory).”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /var/www/USER/www/wp-content/”
    FTP response: Client “127.0.0.1”, “550 Failed to change directory.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (127,0,0,1,156,131).”
    FTP command: Client “127.0.0.1”, “NLST /”
    FTP response: Client “127.0.0.1”, “150 Here comes the directory listing.”
    FTP response: Client “127.0.0.1”, “226 Directory send OK.”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (127,0,0,1,156,152).”
    FTP command: Client “127.0.0.1”, “LIST -a”
    FTP response: Client “127.0.0.1”, “150 Here comes the directory listing.”
    FTP response: Client “127.0.0.1”, “226 Directory send OK.”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “SYST”
    FTP response: Client “127.0.0.1”, “215 UNIX Type: L8”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (127,0,0,1,156,68).”
    FTP command: Client “127.0.0.1”, “NLST /www/”
    FTP response: Client “127.0.0.1”, “150 Here comes the directory listing.”
    FTP response: Client “127.0.0.1”, “226 Directory send OK.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /www/”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/www” is the current directory”
    and so on…

    Vultr (this is the whole log for attempting to remove a plugin). Firstly, again, it goes for the absolute path but fails and dies:

    CONNECT: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “220 Welcome to XXX.convergent-ict.com”
    FTP command: Client “127.0.0.1”, “USER ****”
    FTP response: Client “127.0.0.1”, “331 Please specify the password.”
    FTP command: Client “127.0.0.1”, “PASS <password>”
    OK LOGIN: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “230 Login successful.”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (*,156,102).”
    FTP command: Client “127.0.0.1”, “QUIT”
    FTP response: Client “127.0.0.1”, “221 Goodbye.”
    CONNECT: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “220 Welcome to XXX.convergent-ict.com”
    FTP command: Client “127.0.0.1”, “USER ****”
    FTP response: Client “127.0.0.1”, “331 Please specify the password.”
    FTP command: Client “127.0.0.1”, “PASS <password>”
    OK LOGIN: Client “127.0.0.1”
    FTP response: Client “127.0.0.1”, “230 Login successful.”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (*,156,105).”
    FTP command: Client “127.0.0.1”, “TYPE A”
    FTP response: Client “127.0.0.1”, “200 Switching to ASCII mode.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /var/www/USER/www/wp-content/plugins/”
    FTP response: Client “127.0.0.1”, “550 Failed to change directory.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (*,156,141).”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PWD”
    FTP response: Client “127.0.0.1”, “257 “/” is the current directory”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “PASV”
    FTP response: Client “127.0.0.1”, “227 Entering Passive Mode (*,156,96).”
    FTP command: Client “127.0.0.1”, “CWD /”
    FTP response: Client “127.0.0.1”, “250 Directory successfully changed.”
    FTP command: Client “127.0.0.1”, “QUIT”
    FTP response: Client “127.0.0.1”, “221 Goodbye.”

    Thanks in advance for any help, which will be very greatly received.

    Cheers, Laurie.

    [signature moderated]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    Apart from the whole FTP issue: your actual goal is to copy the data from the old to the new hosting – isn’t it? I do that via scp. It’s much faster than FTP. Example: starting from your target system you fetch the data from the old one:

    scp -r user@oldhosting:/var/www/USER/www .

    Then adjust the permissions via chown if necessary.

    With your FTP problem, however, I do not see the connection to WordPress. FTP is a service in your hosting and not a function that WordPress provides. WordPress can use FTP to install e.g. new plugins and updates, if WordPress is configured accordingly – a way that I would not recommend and you do not see now as a reason.

    Thread Starter brownowl

    (@brownowl)

    Thanks for the reply, but I see I should explain…

    The site is transferred and works in all regards except this FTP problem.

    I set up, run and manage the server it lives on, I am, therefore, the “hosting”. FTP is working perfectly for all users, including this one.

    Other sites on that server aslso work perfectly, all except this one, and my issue is that I cannot see the problem, nor work out the solution, hence my asking for help. Over the years I’ve worked in IT, I’ve learnt that a fresh set of eyes/thinking can often see the issue that I no longer can.

    Cheers, Laurie.

    Moderator threadi

    (@threadi)

    However, I still wonder why you need FTP on the hosting at all? It is a service on the hosting and has nothing to do with WordPress as software. I’m missing the connection right now. Maybe you should rather turn to an Ubuntu community since it is their services that you are here about.

    Thread Starter brownowl

    (@brownowl)

    Because clients use FTP to add and update their plugins, and WP core. I provide what my clients ask for, and that is FTP.

    This issue is only there for one user and then only via WP. I simply can’t see what the problem is, and I’ve spent a lot of time on it. Posting here is, trust me, in desperation.

    In my original post I said “I’ve checked the vsftpd config on both machines, and it’s identical.” The issue is not with FTP, nor with Ubuntu. I know that for sure, so it’s somewhere else.

    Cheers, Laurie.

    Thread Starter brownowl

    (@brownowl)

    Ok, I’ve been through file permissions step by step for a working site and the one that doesn’t work. I can find no difference.

    I have created a new user and a brand new WP installation for that user. I have set the permissions as usual and again checked them finding no difference. And still it can’t find the WP plugin directory in order to delete a plugin.

    I found a “cure” in a post that suggested I add the following to my wp-config.php:

    if(is_admin()) {
    	add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
    	define( 'FS_CHMOD_DIR', 0751 );
    }

    I’ve done that, and the plugin was deleted instantly. Scarily, it didn’t ask for any FTP details, which is a bit of a concern as although it has solved this problem, I still don’t know why it happened in the first place, or what this change has opened my site up to. I’ve also installed a plugin sucessfully, again with no FTP details required.

    It’s clearly a permissions issue, but I really can’t find it, so for completeness, here’s the situation with site permissions and how I set them.

    The installation root is in the “USER/www” directory referred to first in the permissions script below:

    /var is drwxr-xr-x root root
    /var/www is drwxrwxr-x www-data www-data
    /var/www/USER is drwxrwxr-x USER www-data

    and in the user’s tree permissions are set as follows, where “www” is the WP installation root:

    sudo cd /var/www/USER
    sudo chown USER:www-data www
    sudo chmod 775 www
    sudo find . -exec chown USER:www-data {} +
    sudo cd www
    sudo find . -type f -exec chmod 644 {} +
    sudo find . -type d -exec chmod 775 {} +
    sudo chmod 644 index.php
    sudo chmod 775 wp-content
    sudo chmod 775 wp-admin
    sudo chmod 775 wp-includes
    sudo chmod 640 wp-config.php
    sudo cd wp-content
    sudo chmod 644 index.php
    sudo mkdir uploads
    sudo mkdir upgrade
    sudo mkdir languages
    sudo chown www-data:www-data uploads
    sudo chown USER:www-data upgrade
    sudo chown -R USER:www-data languages
    sudo chmod 775 plugins
    sudo chmod 775 themes
    sudo chmod 775 upgrade
    sudo chmod 775 uploads
    sudo chmod 775 languages
    sudo cd languages
    sudo mkdir plugins
    sudo mkdir themes
    sudo chown -R USER:www-data plugins
    sudo chown -R USER:www-data themes
    sudo chmod 775 plugins
    sudo chmod 775 themes

    Can anyone a) find any fault in those permissions please (apart from the duplications added during testing), and b) tell me if what I added to wp-config leaves me insecure?

    I’m not a WP or PHP developer, at all… I just manage Linux servers.

    Many thanks, Laurie.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Strange FTP absolute and relative path errors’ is closed to new replies.