XAMPP permissions on Mac OS X? - macos

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).

Make sure the XAMPP app is running then:
Under General Tab, in XAMPP app, click Open 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/ and enter
Exit, the terminal and you be good to go

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 select Apply to enclosed items...

Following the instructions from this page,
Open the XAMPP control panel (cmd-space, then enter manager-osx.app).
Select Manage Servers tab -> select Apache Web Server -> click Configure.
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 .
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
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

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

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

Best solution for MAC OS Catalina Xampp
Open Finder
Press Cmd + shift + C
Macintosh HD => Users => copy {username}
Open /Applications/XAMPP/xamppfiles/etc/httpd.conf
Find User daemon edit daemon => {username}
Xampp Manage Server => Restart all
If you encounter problems in phpMyAdmin:
1. Browser (Chrome) restart
Goodluck

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.

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

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

What worked for me was,
Open Terminal from the XAMPP app,
type in this,
chmod -R 0777 /opt/lampp/htdocs/

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.
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

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"

Related

VScode unable to save files inside my WSL2 home folder

I'm trying to make WSL2 work for my web projects development and this is driving me crazy!
Basically, i have two options.
1. Save my project files into c drive and access those with WSL (which makes the responses extremelly slow)
2. save my project files into /home/ which makes the project run super smooth, but i'm unable to edit those files with VSCode.
The error that is what follows:
Failed to save 'DefaultSeeder.php': Unable to write file 'vscode-remote://wsl+ubuntu-20.04/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php')
Here is another command to provide your user with sufficient permissions to write to files:
sudo chown -R myuser /path/to/folder
From https://github.com/microsoft/vscode-remote-release/issues/1008
Well, turns out I was being stupid and posted a stupid question.
After many hours trying to make this damn thing work, I was able to do so, by setting the ownership of the folder to my user.
Here is the shell snippet to change the ownership to the current logged in user:
$ sudo find /~~folder-path~~/ -type d -user root -exec sudo chown -R $USER: {} +~
This solved it for me
sudo find /home/ -type d -user root -exec sudo chown -R $USER: {} \;
I had the same problem and spent hours to find this working solution.
For me, it seems to be right one because it doesn't produce problems with 1. too generous file permissions sent to git afterwards and 2. change ubuntu config to fit windows environment (coupling to windows user).
I found the source of this solution on github. Thanks to saltazaur!
https://github.com/microsoft/WSL/issues/4260#issuecomment-729594527
Steps to solve the problem:
Reset (or reinstall) the Ubuntu distro via Windows "Programs and Features"
Note: If you have data in your home directory already, copy it to windows before
Open Ubuntu & follow initial setup (create user)
Add file "/etc/wsl.conf" with:
cd /etc
sudo touch wsl.conf
sudo nano wsl.conf
copy and paste the content from microsoft docs
save with CTRL+X > "Y" > ENTER
restart wsl (or windows, to be sure ;))
At next startup of ubuntu, the settings in wsl.conf will be applied.
The important part in this case is the following line:
options = "metadata,umask=22,fmask=11"
It sets, that all newly created files will use umask 22 (chmod 775) and fmask 11 (chmod 644)
This settings also applies for IDEs like VSCode & PHPStorm.
Happy coding - finally! ^^
In my case, I cannot edit/delete any file directly by File Explorer too, not just VSCode.
After opening Ubuntu 22.04.1 LTS on Windows, run
sudo chown -R my_username my_folder
Note the my_username is the username in the Ubuntu.
This solves my issue.
I've managed to solve this issue as follows:
"Run as administrator" the VS Code
and then open folder -> locate the working folder.
It worked fine for me.

How to open file as root in GUI text editor on mac os

I need all my files in certain directory to be accessible only by root. So I do the chown and chmod commands to set privileges to 700 template where file owner is root. After that if I open files with nano everything works ok: if I run it with sudo I can see contents of files and edit it; if not root then I can see just an empty file which I can't edit or modify. Then I try to open files with Sublime2 as subl 1.txt. With or without sudo it just appears to show an empty file. Then I try sudo open 1.txt to open with the default TextEditor and then I see a message that I don't have permissions. The same if I try anything like sudo open -a (any other text editor from my apps) 1.txt the permissions message is shown. I've tried to google for gksu for mac but people say that sudo is enough. Please guys, any ideas on the topic are welcome. Thank you much!

mkdir/cp in Mac terminal gives "Permission denied" error

I'm trying to copy a directory in terminal from the Downloads directory to a sub-directory within the Applications/ directory, and I keep getting "Permission denied" error. Why is this so?
try
ls -lt
to see access permission of the folder you want copy file into
then use
chmod 777 your_folder_name
to change the access permissions of the folder
If you "right-click -> Get info" the Applications folder you will notice that the permissions for the Applications folder are Read/Write for 'system' or 'admin'. For 'everyone' it's Read-only. If you are not an admin you need to use 'sudo cp -R Downloads/___Test /Applications'. Obviously, you need to enter a password.
MacOS prevents interaction with downloaded files until you confirm that they are safe. You can effectively do this programmatically by running:
xattr -d com.apple.quarantine ~/Downloads/your_file_here
Then you should be able to copy the file.

how to edit and publish my files at same time in mac os?

I have a serious problem. Every time I edit my source code, I have to do a chown username:groupname for my htdocs folder. Now if I have to publish my files and have them executed on the webserver, I have to do a chown www:www for things to work right. I have tried to change my username,groupname in httpd.conf to my login in Mac OS but ownership still gets set incorrectly. I just want to be able to edit my source code and then not have to worry about changing the permissions.
What do I do?
Probably the easiest is to set the sticky bit of the enclosing directory and make www the group of it. So for example if you want to edit files in /Library/WebServer/Documents you would prepare it with
sudo chgrp www /Library/WebServer/Documents
sudo chmod g+s /Library/WebServer/Documents
Then all files you edit (or technically create) in Documents will have www group as well, so as long as your umask is reasonable (e.g. 0022) they will be readable by the web server and you can edit them as you please.

xampp htdocs permission problem OSX

I just installed XAMPP on OSX. I can't add folder on the htdocs via Finder. I can add a folder via the terminal using sudo mkdir foldername. However I want to add folder by not using the sudo command.
I execute ls -ld htdocs and got this output:
drwxr-xr-x# 7 root admin 238 Sep 13 14:11 .htdocs
How do I add myaccount so that I can create folder without having to use sudo? I'm really confused on the use of chown or chmod.
Thanks.
The .htdocs directory belongs to root, which means, as a simple user, you can't modify anything in without using sudo.
Try changing the ownership of that folder, or change permissions on it : chmod 757 .htdocs.( rwx r-x rwx ).
After that you might be able to create a directory in it, either from the command line, or via the Finder.

Resources