4

I am unable to install plugins on my Centos 6 VPS. When I attempt the install I get this:

Installing Plugin: BotDetect WordPress CAPTCHA 3.0.Beta1.7

Downloading install package from
[web path to:]botdetect-wp-captcha.zip…
Unpacking the package…
Could not create directory.
Return to Plugin Installer

UPDATE: This seems to have something to do with permissions -- I'm guessing there's some group that wordpress needs to be part of in order to change folders, create files, etc., but I can't figure out what that group should be. I have no www-data group -- I read something somewhere about this being a requirement. Can somebody tell me what groups and permissions need to exist for WP to operate?

UPDATE: I have chmodded the permissions to my plugin and uploads folders to 777. I also have created an FTP user specifically for Wordpress and made the home directory for that user the same as my Wordpress root folder as recommended HERE. I then changed these lines in the wp-config.php file from:

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__ . "/"));

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

to:

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__));

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . '/wp-settings.php');

This should eliminate the double slash conflict mentioned HERE.

Note -- I was also having a problem uploading media but that issues was resolved with the chmod to 777.

Now when I try to install a plugin I get this:

Unable to locate WordPress Plugin directory.<br>
Return to Plugin Installer

UPDATE: Per suggestions I have run chown -R on my wordpress directory and reverted my wp-config.php file back to this:

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . "/");

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

My permissions look like this. I still have the problem.

[root@ip-MY_IP/wordpress]# ls -l
total 180
-rw-r--r--  1 apache apache   418 Dec 16 07:07 index.php
-rw-r--r--  1 apache apache 19929 Dec 16 07:07 license.txt
-rw-r--r--  1 apache apache  7183 Dec 16 07:07 readme.html
drwxr-xr-x  2 apache apache  4096 Dec 17 14:57 tmp
-rw-r--r--  1 apache apache  4892 Dec 16 07:07 wp-activate.php
drwxr-xr-x  9 apache apache  4096 Dec 16 07:07 wp-admin
-rw-r--r--  1 apache apache   271 Dec 16 07:07 wp-blog-header.php
-rw-r--r--  1 apache apache  4795 Dec 16 07:07 wp-comments-post.php
-rw-r--r--  1 apache apache  3087 Dec 16 07:07 wp-config-sample.php
-rw-r--r--  1 apache apache  3124 Dec 19 06:10 wp-config.php
drwxr-xr-x  6 apache apache  4096 Dec 18 21:03 wp-content
-rw-r--r--  1 apache apache  2932 Dec 16 07:07 wp-cron.php
drwxr-xr-x 12 apache apache  4096 Dec 16 07:07 wp-includes
-rw-r--r--  1 apache apache  2380 Dec 16 07:07 wp-links-opml.php
-rw-r--r--  1 apache apache  2359 Dec 16 07:07 wp-load.php
-rw-r--r--  1 apache apache 31909 Dec 16 07:07 wp-login.php
-rw-r--r--  1 apache apache  8235 Dec 16 07:07 wp-mail.php
-rw-r--r--  1 apache apache 10880 Dec 16 07:07 wp-settings.php
-rw-r--r--  1 apache apache 25665 Dec 16 07:07 wp-signup.php
-rw-r--r--  1 apache apache  4026 Dec 16 07:07 wp-trackback.php
-rw-r--r--  1 apache apache  3015 Dec 16 07:07 xmlrpc.php
user1780242
  • 541
  • 1
  • 10
  • 25

7 Answers7

13

The issue you're having is with ownership of the files. The folder is owned by a different user than the webserver therefore WP can't create a directory for the plugin you're attempting to download.

The changes you have made to wp-config.php need to be reversed.

Then SSH into your server and run:

sudo chown -R apache:apache /path/to/wordpress/dir

Replace apache:apache with a different user:group if your configuration is different.

Nathan Dawson
  • 18,138
  • 3
  • 52
  • 58
  • Where is the user:group configuration defined? I'm assuming user is simply my wordpress username, but I don't recall creating a group for wordpress. I'm not too familiar with user groups yet so am a little in the dark on that. – user1780242 Dec 19 '13 at 13:04
  • To clarify this answer, your File/ Folder User and Group settings need to be correct – these are the User and Group credentials assigned when you upload your Folders/ Files to your server. Edit these permissions using Shell or Putty Edit Group setting: sudo chgrp –R [GROUP NAME] /root/directory/here/ Edit User settings sudo chown –R [USER NAME] /root/directory/here/ – Jonathan Jan 06 '16 at 23:11
  • It wasn't obvious to me right away, but WordPress only asks for FTP if it can't access (???) certain files/dirs. By default, WordPress doesn't need any FTP credentials. So if WordPress is prompting for FTP credentials, I'd say you're either doing something wrong (bad permissions) or your system administrator is not very good because you're on a budget host. Instead of "apache:apache" it might be "www-data:www-data" or something else, depending on your web server. – PJ Brunet Mar 10 '18 at 04:35
  • I already set my ftp user as an owner to the worpdress folder and all inside it. But still got `Installation failed: Could not create directory.` error. What should I do? – alramdein Apr 25 '21 at 15:21
5

Okay, I figured this out based upon the suggestions above. This is how I resolved this issue:

  1. I created a group called ftpusers.

    groupadd ftpusers

  2. I added my wordpress user to this group.

    usermod -a -G ftpusers wordpressuser

  3. I changed ownership of the wordpress folder recursively to my wordpress user:group.

    chown -R wordpressuser:ftpusers wordpress

Voila -- my package installed.

user1780242
  • 541
  • 1
  • 10
  • 25
3

It helps to set the ftp access on the wp-config.php file. as descrived on this post.

https://digwp.com/2010/11/ftp-in-wpconfig/

define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/yourftpfolder/');
define('FTP_USER', 'youruser');
define('FTP_PASS', 'yourpassword');
define('FTP_HOST', 'yourhost.com');
define('FTP_SSL', false);
  • THIS! I'm on a shared server and cannot do that 'sudo chown' wizardry. Providing my FTP credentials like this finally helped. Thanks! – robro Sep 14 '16 at 10:46
1
  • First of all, make sure your WP public folder is owned by the apache user (depending on your system, it should be apache or www-data):

sudo chown -R apache:apache /path/to/wordpress

  • Then edit the vsftpd.conf file

sudo vim /etc/vsftpd.conf

  • and make sure that the line containing the 'write_enable' is uncommented and its value is set to 'YES'

... write_enable=YES ...

1

In my case the wp-content directory only had a plugins.old directory. I created a plugins directory and ran "chmod wwwrun:www plugins/" to get the plugins to install. Running opensuse leap 42.2.

1

I ALWAYS have issues like this in new Wordpress projects cloned from Bitbucket.
What did solve the problem to me was a group of different solutions found here and in some other places, so I am posting this answer as a summary of what I found:
Obs.: I am developing locally, this is not what I suppose you should do in your server! I run these codes on the Wordpress root folder, after cloning the theme content.

  1. Configure git to not track ownership changes (otherwise, it would track change on ALL of the project files)
    git config --global core.fileMode false
    -- you can omit "--global" if you want this configuration to take place only on the current project.
  2. Change ownership to group daemon (I have no www-data group or user locally):
    sudo chown daemon:<my-user> -R *
  3. Change file and folders permissions:
  • files:
    sudo find . -type f -exec chmod 664 {} +
  • folders:
    sudo find . -type d -exec chmod 775 {} +
  • wp-config only:
    sudo chmod 660 wp-config.php

Now it is working fine, but I still do not know why this issue happens in the first place.
Maybe it is because I am running Linux and cloning code made in Windows... maybe not, but I already had problems and had to configure the

-1

Just try chown R apache:apache to the wordpress directory or the entire public directory

Ashok G
  • 161
  • 2
  • 10
  • giving the files to apache user is very insecure – mustafa Feb 27 '19 at 16:38
  • @mustafa I agree on that. to have correct file permissions please check the following link https://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress – Ashok G Mar 01 '19 at 06:39