19

i've installed a LAMP server on my ubunutu 11.04. i've installed wordpress and hooked it right with the MySQL db. i've changed the permissions of the www-data group to read and write files.

every thing is seems to work and i can manage the site through the admin panel, but i can't install plugins cause the system is asking me the FTP details, and i can't seem to go through it.

can any body help? please...

0

11 Answers 11

-1

I usually do this when that happens (only locally, not for production) :

chown -R nobody:nobody /path/to/wordpress
4
  • Does this decrease security? I read that Apache shouldn't own anything, but that may just be someone's opinion.
    – jfa
    Jun 18, 2014 at 19:53
  • 3
    chown: invalid group: ‘nobody:nobody’
    – DaVince
    Sep 6, 2017 at 7:58
  • Well, this comment above is correct, the idea of nobody:nobody probably comes from the entry in /etc/passwd, nobody:nobody. I question the bigger issue of who should own various files, am currently looking into that for uploading Wordpress themes and there's a lot of conflicting info about file ownership. So this is not really a "correct" answer unless mike23 can give a convincing argument and link to some reference material as in, "Provide content for links"
    – JimLohse
    Jun 7, 2019 at 19:05
  • For Asaf or anyone who got here by Googling, check wordpress.org/support/article/hardening-wordpress, have the most locked down permissions and decide if you're willing to open up perms on upload dirs.
    – JimLohse
    Jun 7, 2019 at 19:06
55

The solution I found that worked on my Mac running the built-in Apache2 was to add this to 'wp-config.php'

define('FS_METHOD','direct');

Keep this to a localhost or dev setup and don't use it for production.

8
  • 4
    This is the best solution. Make sure you don't add it to production as it can cause security issues: codex.wordpress.org/Editing_wp-config.php
    – Justin
    Mar 10, 2014 at 21:20
  • 2
    This is the best answer (for local config of WP) Sep 3, 2015 at 12:52
  • 2
    works in Ubuntu 15.10 too..
    – arshad
    Nov 28, 2015 at 7:30
  • 1
    this works in Debian 8 Jan 1, 2016 at 22:17
  • This is the answer without a doubt, for a local WordPress.
    – Adam
    Sep 7, 2018 at 18:14
7

This is a permissions issue. wp-content/plugins must be writable by the web server user.

6

After installing WordPress 5 on Debian 9 Stretch I updated (remotely on localhost) and was prompted for FTP details.

Running these commands in terminal fixed the problem:

chown -R www-data:www-data /var/www/html
chmod -R g+rwX /var/www/html

It's a file-ownership issue.

Code and caveat from turnkeyLinux.com:

Changing file permissions is a trade off (often increasing security reduces user-friendliness and/or usability). For security 'best practice' only the folders that require write access by the webserver should be owned by the webserver. If your webserver has write access everywhere and your server is compromised it makes it easier to hack your WordPress install) but for ease of use giving the webserver ownership should resolve all your issues...

1
  • That worked for me on Ubuntu
    – samu101108
    Aug 11, 2021 at 13:16
5

This is a permissions issue. Here are some steps to fix ownership and r/w permissions in a more secure way:

// check what groups your username belongs to

$ groups

// if your username doesn't belong to www-data then add username to group

$ sudo usermod -a -G www-data username

// exit ssh session (or close terminal window if local) to make group change stick

$ exit

// now give www-data group ownership of /var/www/html (you're not modifying the owner, just changing group ownership here)

$ sudo chgrp -R www-data /var/www/html

// give necessary r/w permissions directories and files to users who are members of www-data

$ sudo find /var/www/html -type d -exec chmod g=rwxs "{}" \;

$ sudo find /var/www/html -type f -exec chmod g=rw "{}" \;

// I like to check things before moving on

$ ls -l /var/www/html/

// you likely don't need to restart apache, but if you want to

$ sudo service apache2 restart

Apache should now have r/w access to /var/www/html as well as any user that you shh/ftp in with that also belongs to www-data

2

Ubuntu Users

Just add define('FS_METHOD','direct'); to wp-config.php and it will work on localhost. Just make sure you don't add it to production version. See: codex.wordpress.org/Editing_wp-config.php

1
  • 1
    This isn't specific to Ubuntu..
    – Tim Malone
    Jun 17, 2016 at 6:32
2

I usualy use :

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

if security not big issue

2
  • This works but if i do that it means i can't do anything in that folder via finder. Never used to have these issues and odd its started this year.
    – v3nt
    May 16, 2018 at 11:16
  • This is fine if security is not a big issue but you don't want to open up all your wordpress files like this for anything connected to the internet :)
    – JimLohse
    Jun 7, 2019 at 19:10
0

This isn't a WordPress problem. You need to refer to the documentation for the LAMP server to check the setup options.

For localhost, you can bypass plugin installation from WordPress and simply copy your plugins into /wp-content/plugins. After you copy them in, go to your WordPress administration and they will show up in your plugins ready to be activated.

Make sure you unzip the plugins and keep them in their folders.

0

You need two things to do

  1. Add WolfieZero has said

    define('FS_METHOD','direct'); in wp-config.php file

At this point you will have following, which one step forward

Unpacking the package…Could not create directory.

2 Then set permission to 777 to wp-content/plugins

After this it will show message like following

Downloading install package from https://downloads.wordpress.org/theme/exclusive.1.0.32.zip…

 Unpacking the package…
 Installing the theme…
 Successfully installed the theme Exclusive 1.0.32.

CHOWN should also work and it is better way of doing it that Server is in owner group.

-1

If you're using mod_php, switch to mod_suphp instead. This has worked for me in the past.

I don't know what package it will be listed as in Ubuntu, but generally it's there somewhere. Works in Fedora.

-1

I don't know if you are answered...but what i have encountered especially when i was working on linux and i just thought maybe other users, especially who are working on linux might find this useful. I was facing the same problem...but i had to use the SSH2 option.

How to install SSH2

apt-get install openssh-server libssh2-php

After that, i had to restart my apache2 server.

Then when i tried to upload my theme i had to use SSH not FTP when asked for credentials.

E.g

 Hostname: localhost

 FTP/SSH Username: admin

 FTP/SSH Password: password

And it worked.

Thanks.

Not the answer you're looking for? Browse other questions tagged or ask your own question.