unable to read and write htdocs folder in XAMPP

I am creating a laravel project within /Applications/XAMPP/htdocs. I used following to apply the read and write privilege to htdocs folder in XAMPP folder

sudo chmod -R 777 htdocs

Then I create the project within /Applications/XAMPP/htdocs

create-project laravel/laravel [Project Name]

It shows error

Installing laravel/laravel (v5.6.12)
[ErrorException]
mkdir(): Permission denied

Does anyone know how to solve this problems? Appreciate for the help

Updated:

I solved this problem by installing the lower version of XAMPP.


Solution 1:

Change document root of the server. I assume your xampp installation folder is

/opt/lampp

Run sudo gedit /opt/lampp/etc/httpd.conf on the terminal to edit httpd.conf file.

You have to change these two lines.

DocumentRoot "/opt/lampp/htdocs"

<Directory "/opt/lampp/htdocs">

Then change /opt/lampp/htdocs directory to any directory in your home folder for example /home/yourUserName/htdocs

Note: Replace "yourUserName" with your username.

After that, those two lines should look like

DocumentRoot "/home/yourUserName/htdocs"

<Directory "/home/yourUserName/htdocs">

After saving the changes run sudo /opt/lampp/lampp restart to restart apache

Now create local projects in your /home/yourUserName/htdocs directory without any permission problem.