I am trying to have a server setup for my web app locally on my MacBook Pro. I have installed Apache, PHP successfully and checked out my web app's code to
/var/www location. Now there's a script in my app that writes a file in
/var/www/someDir. To do so I am using the following line:
$file = fopen($_SERVER['DOCUMENT_ROOT']."/abc.ini", "w");
And on execution I see the following error in error log.
PHP Warning: fopen(/var/www/someDir/abc.ini): failed to open stream: Permission denied in /private/var/www/myscript.php on line 6
someDir is owned by user
abhilash.goje (that's me) and group
wheel. I have tried giving following permissions.
$sudo chmod -R 755 www -> Did not resolve the issue $sudo chmod -R 775 www -> Did not resolve the issue $sudo chmod -R 777 www -> Resolved the issue, but not safe.
permission 777 works but I don't prefer to use this solution as it is not at all safe. Kindly let me how do I set the correct permissions to this folder.
Thanks in Advance!!