If the xampp has the default settings, it is quite a mess. I expand a little the topic.
The problem is with directory and file permissions (they control whether users can read, write, or execute - access and run - files and directories.)
You are logged in as username:group (replace username and group with yours, for example username=joedoe, group=admin, so joedoe:admin) and the Apache runs as daemon:daemon (i.e. user=daemon and group=daemon).
So the problems is not only the read, write, execute... but also owner and group.
When a program save a file (for example, PHP file_put_content), will be saved with permission 644 and belong to daemon:daemon (you can see in terminal ls -al
. To be able to save in a directory, the directory must have a permission to allow this. It was suggested in this thread 777 so many times, the last "7" belonging to "others" (owner, group, others) is responsible here as you and httpd/Apache are different users belonging to different groups.
Even if you save the file in that directory, you may still run into problems. In this example, you will not be able, for example, to use your editor to delete the files written in that directory by the program because they will have the permission 644 and do not belong to you.
Understanding the problem, you know how to fix it. Changing the ownership of all files to daemon:daemon may work if you do not work on that files in an editor. In addition, many other things will be problematic. For example, you may want to install something with brew (let's say xdebug) that works with XAMPP... what you install with brew will belong to user:group and you have XAMPP with daemon:daemon... I believe that is much better to do it the other way around.
Change the owner and group of XAMPP to your username:group.
In the thread there are instructions, on short:
- open the
httpd.conf
(Manage Server > Configure > Open Conf File) and replace the user and group "daemon" with yours. (Something like "User daemon" and "Group daemon").
sudo chown -R admin:admin /path/to/xampp_root_directory