I was trying to install a Joomla on my Macbook Air under XAMPP. I successfully installed it, but when I try to open the front-end, I keep getting this mkdir():permission denied error.

Two questions raised while I was trying to solve this problem:

1) I noticed when I do ls -l, owners of some folders are myname:admin, while those of other folders are root:admin. I am the only user of this computer and the myname user should have all root privileges. I don't understand:

A.why when I do chmod I had to sudo chmod.

B.why there are folders with different owner.

2) To solve the problem, I violently change owner of all related files and directories to root:root and permissions of those to 0777. But eventually I will have to move this over to production server, it is not wise to keep the owner and permission like this. Is there any better way to solve the problem while keeping the owner/permission setting as intact as possible?

  • Now why would you change the octals to 777? That means you are setting the files to have reade/write/executable access for the owner, group, and everyone else. That's not very safe. – ryekayo Mar 29 '16 at 15:14

OS X operates a bit like Ubuntu in that the default user does not have administrative privileges directly, but rather is given them through sudo. There is still a root account, even if you can't log into it. This is done for security reasons - a great deal of 2000s-era Windows malware got access to do bad things at a system level because every command users ran was as an administrator.

The answer to why certain files were owned by root depends on which specific files they were and how they got there. But I would guess:

  • system files created by OS X are root because you aren't normally supposed to touch them
  • things created by the xampp installer likely set the permissions to root because you're not supposed to mess with them
  • and/or you ran the installer as root (via sudo) and that's the user that was then picked up and given ownership

You had to use sudo on your chown/chmod command because unprivileged users aren't allowed to change the ownership of other users' files and directories. Imagine if they could! I could just give myself permission to edit your home directory, or /etc/passwd!

You are correct in ascertaining that 777 is not production-appropriate. You hopefully won't be using xampp in production, as it's explicitly not designed for that, but beyond that, in /var/www (or wherever you're putting this):

  • things that need to be modified by the web server (like autofilled cache directories) can be group-writable
  • everything else should only owner-writable
  • everything should be owned by :www-data (or whatever group apache is in)

This prevents an attacker who finds a vulnerability in one of your hosted scripts from being able to write much of anything, but still makes it easy for you to push changes to the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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