Ubuntu 12.04 Tips and Tricks

In this article we would set the permission of htdocs folder.

htdocs folder contains the web contents. In our previous articles we have installed XAMPP and also seen how to start automatically XAMPP on login.

XAMPP local web server serves websites from htdocs folder by default.

Default location of htdocs folder is /opt/lampp/htdocs .

You would not be able to create files/folders in this folder unless you are logged in from root account. And as we have suggested in our earlier article you should not use root account unless you have no other options. We can change the ownership of htdocs folder so it would be writeable for our user account.

To change the ownership of htdocs folder open the terminal.

We need user name to change the ownership. If you know username skip this command.

To know currently logged in username run following command

who am i
xampp fix permission who am i

To change ownership of htdocs folder run following command. [Replace username with your own username]

sudo chown -R username:username /opt/lampp/htdocs
xampp fix permission chown command

We also need to update httpd.conf file. Run following command to open apache configuration file

sudo gedit /opt/lampp/etc/httpd.conf
xampp fix permission gedit

find following lines

User nobody
Group nogroup

Replace nobody with your user name and save the file

xampp fix permission username in file

Logout from user and login back.

Now you can create, delete, and manage files / folder in htdocs folder. To test it

open htdocs folder

xampp fix permission htdocs folder

create a test.php file

xampp fix permission text file

open test.php and write a simple php code for testing. Save the file

xampp fix permission text file with php

access file from browser

xampp fix permission test file in browser