17

I'm trying to install Wordpress using the following installations. However, when I attempt to open the browser to set up Wordpress, I get an error that there is a problem establishing a database connection. I think it's because of an error I get when I run the chown command.

http://www.techkaki.com/2011/04/how-to-install-wordpress-locally-on-ubuntu-10-10-with-lamp/

chown -R www-data /var/www/wordpress

I get a ton of error messages:

...
chown: changing ownership of `/var/www/wordpress/wp-admin/network/themes.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/users.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/index.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/sites.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/user-new.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/setup.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/theme-install.php': Operation not permitted
chown: changing ownership of `/var/www/wordpress/wp-admin/network/plugins.php': Operation not permitted

Anyone know what's up with this?

3 Answers 3

31

You have to be root to change the owner of files/directories.

sudo chown -R www-data /var/www/wordpress

If you're getting an error like Operation not permitted, just type:

sudo !!

at the prompt to execute the last command with root priviledges. This way, you don't have to retype chown -R www-data /var/www/wordpress.

5
  • 11
    For those who've never seen this before: !! does history expansion, the last executed command in the shell to be precise.
    – Lekensteyn
    Jul 26, 2011 at 9:33
  • @EricCarvalho he maybe meant that to *change to/from other users but yourself you need root
    – Braiam
    Nov 9, 2013 at 0:43
  • @Braiam I'm not sure what he meant... The idea wasn't changed. I just reformatted it and the previous reviewer only increased the original text's verbosity. Nov 9, 2013 at 1:16
  • in my case that is not working. I am working with NFS could that be the problem? /home type nfs4 (rw,addr=147.142.39.202,clientaddr=147.142.39.163,_netdev) Jun 12, 2015 at 17:11
  • even with 'sudo', it does not work.
    – user67470
    Sep 27, 2018 at 13:34
3

If you're not root, you'll need to become root to set these permissions:

sudo chown -R www-data /var/www/wordpress
3

Besides being root, as others have pointed out, there is another more flexibile way to manage this privilige. You can also give files away via chown if your process / thread has the CAP_CHOWN Posix capability. For more info, and how to get that capability, see http://manpages.ubuntu.com/manpages/intrepid/man7/capabilities.7.html Unfortunately it doesn't yet seem to be possible for a process to gain specific capabilities like this based on attributes of an executable file. Either the process would have to be configured this way by another privileged process, or the executable would have to be fully setuid, and then give itself the capability before dropping root priviliges as a normal safety precaution.

A tip of the hat to Can't change owner (user or group) of directory which I have all rights on? - Super User

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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