XAMPP Non-root access to htdocs without changing permissions.

So you install XAMPP (Apache, PHP, MySQL development environment) and are ready to create your world famous web application but XAMPP installs into opt, which requires root to write to the files. You could change permissions, add groups, or symlink with some variation but why? Apache can serve docs from anywhere with a few changes to the config file.

For a simple config where you only care about working in a single folder follow these steps to place the htdocs folder in your home directory. First create the folder htdocs in home. You can create it anywhere you like and name it what ever you like, just adjust the path in the config. I created htdocs in /home/mohawke.

Fire up the XAMPP interface:

/opt/lampp$ sudo ./manager-linux-x64.run

You’ll see the typical admin window. Click on Configure.

XAMPP admin panel

A second window will open and give you access to the apache.conf file.

XAMPP config window

Click to Open Conf File. The config file will open in the text editor and since you have to run the admin tool as root it is writable by default. All you need to do is search for DocumentRoot, which should be around line number 229, and change the path to your folder. You also need to change the line below.

Apache conf

Once saved just start Apache and start working. If you want multiple folders serving different web apps you can create VirtualDirectories.