Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

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.

share|improve this answer
4  
For those who've never seen this before: !! does history expansion, the last executed command in the shell to be precise. –  Lekensteyn Jul 26 '11 at 9:33
    
@EricCarvalho he maybe meant that to *change to/from other users but yourself you need root –  Braiam Nov 9 '13 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. –  Eric Carvalho Nov 9 '13 at 1:16
add comment

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

sudo chown -R www-data /var/www/wordpress
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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