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.
Tried the above but the option to amend the permission was not available for the htdocs folder,
My solution was:
- Open applications folder
- Locate XAMPP folder
- Right click, get info (as described above)
- In pop-up window locate the 'sharing & permission' section
- Click the 'locked' padlock symbol
- Enter admin password
- Change 'Everyone' permissions to read & write
- 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.
- Re-lock the padlock symbol
- 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).
For latest OSX versions,
- Right click on the folder
- Select
Get Info
- Expand the
Sharing & Permission
section - Unlock the folder by clicking lock icon on bottom right-corner
- Now, select the user list and enable
Read & Write
privilege for the users - Click on the
+
icon to add username Finally click
settings icon
and selectApply to enclosed items...
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
Make sure the XAMPP app
is running then:
- Under
General
Tab, inXAMPP app
, clickOpen Terminal
- A terminal will be launched with something like,
root@debian:~#
, on the terminal shell - on that terminal shell, type,
chmod -R 0777 /opt/lampp/htdocs/
andenter
Exit
, the terminal and you be good to go
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
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:
If you copy a new folder into the htdocs after this, you need to repeat the process for that folder to have write permission.
When you move your files to the live server, you need to also chmod the appropriate files & folders on the server as well.
Following the instructions from this page,
- Open the XAMPP control panel (cmd-space, then enter
manager-osx.app
). - Select
Manage Servers
tab -> selectApache Web Server
-> clickConfigure
. - Click
Open Conf File
. Provide credentials if asked. 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>
Save and close.
- Using the XAMPP control panel, restart Apache.
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 .
if you use one line folder or file
chmod 755 $(find /yourfolder -type d)
chmod 644 $(find /yourfolder -type f)
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
What worked for me was,
- Open Terminal from the XAMPP app,
- type in this,
chmod -R 0777 /opt/lampp/htdocs/
来源:https://stackoverflow.com/questions/9046977/xampp-permissions-on-mac-os-x