Tag Archives: chown

Why is WordPress asking for My FTP Details? (Ubuntu) Tips, Tricks and Tutorials 27 MAY 2014

I had an instance where every time I tried to add either a theme or plugin to my fresh WordPress install, WordPress would respond with something along the lines of “To perform the requested action, WordPress needs to access your web server”, followed by a form asking me to enter all the server’s FTP details.

It is not an issue that I usually encounter, and some quick Internet delving provided the answer – essentially WordPress was figuring out as to whether or not it had access to the filesystem, and if it didn’t, well then it would try and accomplish what it needs to do via FTP.

With that knowledge now gleaned, it made perfect sense – in this particular case I had only opened up the wp-content folder for writing, meaning that WordPress was technically blocked from writing to the filesystem anywhere other than that specific folder.

To solve this is relatively simple. If you have SSH root access to the Ubuntu server, then it is simply a matter of logging in and changing the ownership of the entire WordPress directory. So for example, if Apache is running as www-data, you could accomplish the ownership change via:

chown -R www-data: /home/www/wordpressdirectory

That should resolve the issue outright. (Note that not all versions of chown are equal. If that command does not work, see your local chown man page for usage information.)

Well, the above certainly solved my issue.

horizontal wordpress logo landscape

Bonus: A handy tip if you aren’t sure what user you instance of Apache is running as, create a test script with the following content:

<?php echo(exec("whoami")); ?>

Clever.

Ubuntu Server: Resolve Can’t Open ‘.svn/lock’ Permission Denied Error Tips, Tricks and Tutorials 05 DEC 2013

svn-logoIt’s rather frustrating when you are trying to execute an SVN command only to be rebuffed with the infamous “Can’t Open ‘.svn/lock’ : permission denied” error message string. Now this message is usually an indication that currently another session is running an SVN operation which is still in process, hence the locked message, but in the case that you are the only one running SVN commands on the box and this is the only terminal running all day, well then it’s understandable to be pretty annoyed.

But it turns out that there is another reason why this message might be rebuffing you – if you are currently not logged in as the user with rights to the files contained in the svn checkout, then needless to say you won’t have access to the .svn/lock file!

Obviously the resolution is to simply switch over to the correct user account and run the SVN command, but if you can’t, well then you could always just steal the rights to the checked out files, assuming you have sudo rights of course!

In practice:

# go to the path of your project
cd /PATH/TO/MY/PROJECT

# reset ownership
# NOTE: replace apache.staff with your user and group
sudo find . -exec chown apache.staff {} \;

# reset permissions
# NOTE: replace ug+rw with your file permissions
sudo find . -exec chmod ug+rw {} \;

# Now you can run the cleanup command to repair your .svn folders
svn cleanup

Useful to know.