WordPress – Enable wordpress to install content via vsftpd

permissionsvsftpdWordpress

I installed WordPress on an Amazon EC2 instance, and have trouble enabling WP to install themes, plugins etc. For example, theme installation failed with:

Installation failed: Could not copy file. harmonic/404.php

I use vsftpd and have created a user named wordpress.

This looks like a file permission problem, but I've set the permissions according to some online instructions and cannot spot the problem:

[ec2-user@ec2 wordpress]$ ls -lah
total 196K
drwxr-sr-x  5 wordpress www 4.0K Aug 29 14:29 .
drwxrwsr-x  3 root      www 4.0K Aug 29 14:45 ..
-rw-r--r--  1 wordpress www  418 Sep 25  2013 index.php
-rw-r--r--  1 wordpress www  20K Mar  5 20:14 license.txt
-rw-r--r--  1 wordpress www 7.2K Jul 19 17:34 readme.html
-rw-r--r--  1 wordpress www 5.4K May 24 21:02 wp-activate.php
drwxr-sr-x  9 wordpress www 4.0K Aug 16 18:23 wp-admin
-rw-r--r--  1 wordpress www  364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 wordpress www 1.5K May 23 16:44 wp-comments-post.php
-rw-r--r--  1 wordpress www 3.0K Aug 29 09:42 wp-config.php
-rw-r--r--  1 wordpress www 2.8K Dec 16  2015 wp-config-sample.php
drwxr-sr-x  5 wordpress www 4.0K Aug 29 14:29 wp-content
-rw-r--r--  1 wordpress www 3.3K May 24  2015 wp-cron.php
drwxr-sr-x 17 wordpress www  12K Aug 16 18:23 wp-includes
-rw-r--r--  1 wordpress www 2.4K May 23 16:44 wp-links-opml.php
-rw-r--r--  1 wordpress www 3.3K Apr 14 17:53 wp-load.php
-rw-r--r--  1 wordpress www  34K Jun 14 21:51 wp-login.php
-rw-r--r--  1 wordpress www 7.7K Jul 13 12:37 wp-mail.php
-rw-r--r--  1 wordpress www  14K Aug 13 16:02 wp-settings.php
-rw-r--r--  1 wordpress www  30K May 24 20:44 wp-signup.php
-rw-r--r--  1 wordpress www 4.0K Nov 30  2014 wp-trackback.php
-rw-r--r--  1 wordpress www 3.0K Jul  6 12:40 xmlrpc.php

[ec2-user@ip-172-31-27-36 wp-content]$ ls -lah
total 24K
drwxrwsr-x  5 wordpress www 4.0K Aug 29 14:29 .
drwxr-sr-x  5 wordpress www 4.0K Aug 29 14:29 ..
-rw-rw-r--  1 wordpress www   28 Jan  8  2012 index.php
drwxrwsr-x  5 wordpress www 4.0K Aug 29 14:45 plugins
drwxrwsr-x  5 wordpress www 4.0K Aug 29 14:29 themes
drwxrwxr-x 17 wordpress www 4.0K Aug 29 15:04 upgrade

I chowned the directory /var/www/html/wordpress to the user wordpress – was that correct?

Why do vsftpd logs contain nothing on the failed operations?

Best Answer

  1. Vsftpd doesn't care about WordPress failing to copy files, that's not an error to it. It would only be an error if there was an issue during file transfer or access to a file over SFTP, but that's not what's happening here. The problem is during the install, the files are already on the server.

  2. Neither of your commands shows the actual directory in question, harmonic, which is likely within your themes directory. This is where the issue is occurring so we'd need to see the permissions on that directory.

  3. As Christian mentioned you should be using WP_DEBUG to get the real error, but you don't need to bother with logging it, just use the following:

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', true );
    

    It should be set to display by default and those errors should be displayed on the page where you're trying to install the theme, so look there.

  4. Those files and directories should be owned by the Apache user, NOT your vsftpd user. If Apache is using www then it should be changed to that. Most commonly it's using www-data, so I'd check either with looking at the running process:

     ps aux | egrep '(apache|httpd)'
    

    Or in the Apache configuration file at /etc/apache2/httpd.conf if you're running Ubuntu/Debian or at /etc/httpd/conf/httpd.conf if you're running CentOS/RHEL. You can find it listed as the User directive.

Related Topic