75

I installed XAMPP 1.7.3 on Mac OS X 10.6.8 without changing any defaults.

The webserver seems to work okay, but the permissions on the htdocs directory are set to "Read only" for everyone other than system. So (a) I have to provide root password every time I copy in web content, and, more problematic, (b) NetBeans says it can't create a target directory, and doesn't even generate the index.php file in the source directory.

Do I just need to manually change permissions on the htdocs directory, or is there some more global XAMPP setting that should be changed? Running NetBeans as root seems a bit extreme.

NiRUS
  • 3,901
  • 2
  • 24
  • 50
Andrew
  • 1,222
  • 1
  • 10
  • 14

15 Answers15

215

Tried the above but the option to amend the permission was not available for the htdocs folder,

My solution was:

  1. Open applications folder
  2. Locate XAMPP folder
  3. Right click, get info (as described above)
  4. In pop-up window locate the 'sharing & permission' section
  5. Click the 'locked' padlock symbol
  6. Enter admin password
  7. Change 'Everyone' permissions to read & write
  8. In the get info window still, select the 'cog' icon' drop down option at the very bottom and select 'Apply to enclosed items' this will adjust the permission across all sub-folders as well.
  9. Re-lock the padlock symbol
  10. Close the 'Get Info' window.

Task complete, this will now allow you to populate sub-folders within the htdocs folder as needed to populate your website(s).

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Duello
  • 2,190
  • 1
  • 13
  • 3
  • 10
    This had me stumped for a while - I had changed the permissions on my folder within 'htdocs', but the key was changing the permissions on the XAMPP folder itself. Incidentally, this can also be done from the terminal using `chmod -R 0775 XAMPP/` from the `Applications` directory. – head in the codes Jul 30 '13 at 14:21
  • 16
    Warning: if you do this on the main xampp folder, it will mess up things like phpmyadmin etc... My solution was just to enable it on the htdocs directory only. – James Alvarez Aug 06 '15 at 10:39
  • 2
    I did this on only my /wordpress_site/wp-content folder and it worked. Able to now install plugins and themes. Do you recommend changing file permissions back to originals before FTP'ing to online hosting provider? – Matthew Oct 22 '16 at 16:17
  • This didn't work for me for all folders (annoyingly) but the other solution did https://stackoverflow.com/a/55412980/1391681 – Nathan Todd Jan 23 '20 at 15:19
64

Make sure the XAMPP app is running then:

  1. Under General Tab, in XAMPP app, click Open Terminal
  2. A terminal will be launched with something like, root@debian:~#, on the terminal shell
  3. on that terminal shell, type, chmod -R 0777 /opt/lampp/htdocs/ and enter
  4. Exit, the terminal and you be good to go
Bryan Kimani
  • 921
  • 7
  • 11
28

For latest OSX versions,

  1. Right click on the folder
  2. Select Get Info
  3. Expand the Sharing & Permission section
  4. Unlock the folder by clicking lock icon on bottom right-corner
  5. Now, select the user list and enable Read & Write privilege for the users
  6. Click on the + icon to add username
  7. Finally click settings icon and select Apply to enclosed items...

    enter image description here

Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125
13

Following the instructions from this page,

  1. Open the XAMPP control panel (cmd-space, then enter manager-osx.app).
  2. Select Manage Servers tab -> select Apache Web Server -> click Configure.
  3. Click Open Conf File. Provide credentials if asked.
  4. Change

    <IfModule unixd_module>
    #
    # If you wish httpd to run as a different user or group, you must run
    # httpd as root initially and it will switch.  
    #
    # User/Group: The name (or #number) of the user/group to run httpd as.
    # It is usually good practice to create a dedicated user and group for
    # running httpd, as with most system services.
    #
    User daemon
    Group daemon
    </IfModule>
    

    to

    <IfModule unixd_module>
    #
    # If you wish httpd to run as a different user or group, you must run
    # httpd as root initially and it will switch.  
    #
    # User/Group: The name (or #number) of the user/group to run httpd as.
    # It is usually good practice to create a dedicated user and group for
    # running httpd, as with most system services.
    #
    User your_username
    Group staff
    </IfModule>
    
  5. Save and close.

  6. Using the XAMPP control panel, restart Apache.
  7. Navigate to the document root of your server and make yourself the owner. The default is /Applications/XAMPP/xamppfiles/htdocs.

    $ cd your_document_root
    $ sudo chown -R your_username:staff .
    
  8. Navigate to the xamppfiles directory and change the permission for logs and temp directory.

    $ cd /Applications/XAMPP/xamppfiles
    $ sudo chown -R your_username:staff logs
    $ sudo chown -R your_username:staff temp
    
  9. To be able to use phpmyadmin you have to change the permissions for config.inc.php.

    $ cd /Applications/XAMPP/xamppfiles/phpmyadmin
    $ sudo chown your_username:staff config.inc.php
    
uweriii
  • 18
  • 4
Cameron Hudson
  • 3,190
  • 1
  • 26
  • 38
  • 1
    Thank you, you've been really a great help – Nabeel Khan Mar 19 '19 at 00:51
  • 2
    I've followed for this instructions, but I have a problem with MySql Database can't be running. – CrashBurn Oct 24 '20 at 05:57
  • This was it, thank you! It's unbelievable that even after 4 years XAMPP staff still hasn't resolved this. – Vladimir Jovanović Jan 21 '22 at 12:50
  • I did not have to change the ownership of logs, temp or config.inc.php. I had to change the ownership of /Applications/XAMPP/xamppfiles/temp/mysql. I had to set it to "everyone" . In addition to my_username or staff. – Vishwas Feb 23 '22 at 17:02
11

For new XAMPP-VM for Mac OS X,
I change the ownership to daemon user and solve the problem.

For example,

$ chown -R daemon:daemon /opt/lampp/htdocs/hello-laravel/storage
Johnny
  • 1,824
  • 23
  • 16
  • My solution is to: chown -R bitnami:root I am using composer, and have one folder in htdocs called "apps".. and under my developing webapps. and to keep it even more simple if I run some updates trough composer to the apps, I created a simple do_chown.sh script in root folder for easy access when clicking Terminal button, and it simply does a chown -R bitnami:root /opt/lampp/htdocs/Apps/ – Tom Oct 02 '19 at 13:14
6

If you use Mac OS X and XAMPP, let's assume that your folder with your site or API located in folder /Applications/XAMPP/xamppfiles/htdocs/API. Then you can grant access like this:

$ chmod 777 /Applications/XAMPP/xamppfiles/htdocs/API

And now open the page inside the folder:

http://localhost/API/index.php
Denis Kutlubaev
  • 15,320
  • 6
  • 84
  • 70
  • 1
    This is one of correct answers. It works for me. Use `sudo chmod -R 0777 /Applications/XAMPP/xamppfiles/htdocs/` if you need to do it recursively – Eranda Oct 10 '16 at 04:57
  • 4
    Both of those answers are incorrect, as setting folder permissions to 777 is a security risk. the correct answer would be following: https://stackoverflow.com/a/48931236/4766230 – Ed T. Nov 13 '18 at 18:58
4

Best solution for MAC OS Catalina Xampp

  1. Open Finder
  2. Press Cmd + shift + C
  3. Macintosh HD => Users => copy {username}

  4. Open /Applications/XAMPP/xamppfiles/etc/httpd.conf

    Find User daemon edit daemon => {username}

  5. Xampp Manage Server => Restart all

If you encounter problems in phpMyAdmin:

1. Browser (Chrome) restart

Goodluck

2

Go to htdocs folder, right click, get info, click to unlock the padlock icon, type your password, under sharing permission change the priviledge for everyone to read & write, on the cog wheel button next to the + and - icons, click and select apply to all enclosed items, click to accept security request, close get info. Now xampp can write and read your root folder.

Note:

  1. If you copy a new folder into the htdocs after this, you need to repeat the process for that folder to have write permission.

  2. When you move your files to the live server, you need to also chmod the appropriate files & folders on the server as well.

j0k
  • 22,600
  • 28
  • 79
  • 90
  • So it seems like there's not a global XAMPP setting, and manually changing permissions is the way to go. Hmm ... – Andrew Aug 16 '12 at 01:44
  • at the moment, yes. I haven't found any work around and xampp forums have no solutions. If u find a solution plz post it, I would like to know. – Gabriel Nwoffiah II Aug 16 '12 at 05:52
1

if you use one line folder or file

chmod 755 $(find /yourfolder -type d)
chmod 644 $(find /yourfolder -type f)
Asil ARSLAN
  • 1,066
  • 2
  • 14
  • 31
  • 2
    When you have too many files or folders, this fails with a "argument list too long". A better approach would be to do `find /yourfolder -type d -exec chmod 755 {} \;` and `find /yourfolder -type f -exec chmod 644 {} \;` which have the same effect. – Alejandro Iván May 13 '19 at 17:01
1

You can also simply change Apache Conf file to a different User Name and keep the group:

Apache Conf Applications/Xammp/etc/..

User 'User' = your user name in Mac os x.

Group daemon

sudo chown -R 'User':daemon ~/Sites/wordpress 

sudo chmod -R g+w ~/Sites/wordpress
wogsland
  • 9,106
  • 19
  • 57
  • 93
rickb
  • 11
  • 2
  • So if you need to update plugins etc.. then 'Wordpress' can access the files. Otherwise Wordpress can not update the files. Note: For Mac OS X only.. – rickb Feb 11 '17 at 01:50
1

What worked for me was,

  • Open Terminal from the XAMPP app,
  • type in this,

chmod -R 0777 /opt/lampp/htdocs/

1

If you are running your page on the new XAMPP-VM version of MacOS you will have to set daemon as user and as group. Here you can find a great step-by-step illustration with screenshots from aXfon on how to do this.

As the htdocs folder under XAMPP-VM will be mounted as external volume, you'll have to do this as root of the mounted volume (root@debian). This can be achieved through the XAMPP-VM GUI: See screenshot.

Once you are running as root of the mounted volume you can as described above change the file permission using:

chown -R daemon:daemon /opt/lampp/htdocs/FOLDER_OF_YOUR_PAGE

Source (w/ step-by-step illustration): aXfon

ft-be
  • 103
  • 1
  • 1
  • 7
  • dead link. also on my macos version of xampp (xampp-osx-7.4.27-2) htdocs is in: /Applications/XAMPP/xampfiles/htdocs (not /opt/lampp/ ) – jcansell Apr 13 '22 at 15:41
0

This Solved WordPress Filesystem Permissions in Bitnami XAMPP

By changing the file permissions in apps/wordpress folder mounted on MAC XAMPP-VM shown in the below screenshot.

enter image description here

sudo chown -R bitnami:daemon TARGET # [ Replace "TARGET" with your file/folder path ]
find TARGET -type d -print0 | xargs -0 chmod 775
find TARGET -type f -print0 | xargs -0 chmod 664
chmod 640 TARGET/wp-config.php

Source: bitnami

TARGET - Replace placeholder for your mounted filesystem wordpress path eg: '1.1.1.1/lampp/apps/wordpress'

Now you can edit your themes in VS-Code or any developer editor of your choice.

NOTE: This should be done only in your development environment. Production build permissions are different & above doesn't apply

NiRUS
  • 3,901
  • 2
  • 24
  • 50
0

The above worked only for some directories but didn't for all root files. To change root files permissions, open Xampp app, within Xampp app click button 'open terminal'. once there do the following:

 - go to root directory: cd ..  
 - got to directory where lamp is located: cd opt
 - change lampp permissions: chown -R bitnami:root lampp

note: you can replace bitnami with your user, and root with your group.


as a second alternative that worked for some files:

go to your users folder in finder and find the .bitnami hidden folder, access xampp folder within it and change permissions:

  • /Users/username/.bitnami/stackman/machines/xampp
  • right click xampp folder under machines and change permissions to read & write
  • apply to enclosing folders with "cog icon"
Pablo
  • 1
  • 2
0

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:

  1. 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").
  2. sudo chown -R admin:admin /path/to/xampp_root_directory
Florin Sima
  • 1,495
  • 17
  • 13