After installing XAMPP on Linux, the htdocs folder (default: /opt/lampp/htdocs
) can only be written to by root. Although this is normal since the installer has been executed as root, we would still like to be able to create, edit, and remove content from htdocs within our file manager or text editor, without the need for sudo
.
Requirements:
XAMPP
installedsudo
Note: The steps below are done on Ubuntu 16.04, but they should also work on any other Linux distribution.
Warning: These permissions are safe on local environments such as XAMPP. I do not recommend using this for production.
First we need to check what username should have the ownership. The command whoami
returns the current logged in user:
$ whoami
ibrahim
or
$ echo $USER
ibrahim
Based on the results above the command should be:
$ sudo chown -R ibrahim:ibrahim /opt/lampp/htdocs
Now we can write to htdocs!