ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Operating Systems

How to Install XAMPP on Ubuntu Linux - Setting Permissions to Create folder in htdocs

Updated on April 30, 2012

Installing Xampp on ubuntu linux is very easy and it takes few minutes to get server running. What is Xampp ? Xampp is a development web server that has Apache, MySQL, Perl and PHP which makes a perfect package for web development. If you're interested in creating php or perl web apps then all you need to do is install xampp on your system and run the server.

Information on this page will work with most of the modern and older versions of ubuntu installation. As the instructions are the same for almost every linux distribution (except package name and installation part). If you're using windows operating system then you should consider reading xampp windows installation.

Download XAMPP

You need to download the xampp package of your choice. You can choose full package (77mb) or development package (34mb) depending on your needs. I found that development package is enough for my needs. You get almost everything that you need to test the web apps.

Download Xampp from apache friends website.

XAMPP Installation on Ubuntu

We're going to navigate to the downloads directory and going to install xampp from there.

cd Downloads

You'll get prompt set on /Downloads directory in terminal.

Ubuntu requires root privileges for any type of software installation or configuration. So you have to enter su or sudo command in terminal.

sudo tar xvfz xampp-linux-1.7.7.tar.gz -C /opt

That's all. You've xampp installed in your /opt directory. You can browse to this directory and check if the files are extracted properly.

XAMPP on Linux
XAMPP on Linux

Testing XAMPP Server

Now that we have all the files and stuff set, let's test the xampp server. Type the following command in terminal.

sudo /opt/lampp/lampp start

Make sure that you use the above command every time when you want to run xampp server. You need to type sudo before executing the start script. You don't need sudo for shutting down web server though. You can also use batch scripts at startup to start xampp if you're using the machine exclusively for web development purpose.

Open firefox or chrome in ubuntu and check the following web address.


You'll notice the xampp welcome page on this address. Let's see if we can edit any files or folders in htdocs directory.

How to Create folder in htdocs directory of Xampp in Ubuntu

As you noticed earlier that you can't create any file or directory in this folder. You check the permissions on htdocs directory or any other directory in lampp folder.

ls -ld /opt/lampp/htdocs

As you can see it shows the owner and the groupname of the htdocs directory. As you're not part of that group or not even owner that is why you can't edit the files or create new folder in that directory.

drwxr-xr-x 4 user nogroup 4096 2011-10-31 12:43 /opt/lampp/htdocs

Now that there is no group listed as "nogroup'. You have to add the group in order to let your username manipulate the directory or files in it.

sudo groupadd www

We're creating group www here and then we'll add the group permission to the htdocs directory.

sudo chgrp -R www /opt/lampp/htdocs

We need to set the permission for this directory so that our current user can use the directory.

sudo chmod 2775 /opt/lampp/htdocs

Once you do that logout from the system to let the change take effects. Once you log back in, you need to run this command to check the permission and the group for htdocs folder.

ls -ld /opt/lampp/htdocs

Permissions are changed and now we need to add our user to this user group.

sudo usermod -aG www username

sudo chown -R username path/to/htdocs

Inset your username in the field and run the command. You now have the user in the group. Log out again and check the permission and user in this group.

Now that you can create, move and delete stuff from this document, xampp will be more easy to use for your own web-apps. Let me know if this guide helps you in anyway.


    0 of 8192 characters used
    Post Comment

    • profile image

      Naoman 4 years ago

      Thank you so much. It was very helpful/

    • profile image

      nepo 4 years ago

      thanks alot my friend...tryed so many tutorials this night to get this to work..but it made it more and more worse..almost wanted to uninstall ubuntu but then i found your article and now everything works! thanks alot so good!!

    • profile image

      Hadi 5 years ago

      You just make it easy step-by-step tutorial .


    • profile image

      steven 5 years ago

      nice guide!

    • profile image

      Raffaele 6 years ago

      You solved my problem.