Thursday, September 6, 2012

Installing Xampp-1.7.7 Web server in Ubuntu 11.10 or above

Installing Xampp-1.7.7 Web server in Ubuntu 11.10

If you are a web designer/developer, you need to have a running local server to test your website. Installing a full pledged server and all of its components manually is a very tedious task because you first need to install the actual server (like apache) then download all modules that you need (MYSql, PHP, etc) and configure them to make all the bits and pieces to work together. Thanks to folks at apachefriends.org, we can have a working server with all of the required modules (Apache, PHP, MYSql, etc) just by installing a single application called Xampp. In this post we will see how to install Xampp-1.7.7 on Ubuntu 11.10.

Download the package

Fire up the terminal and issue the following command to download the .tar.gz package


If the download is interrupted for some reason, fear not, because wget can resume interrupted downloads. Simply execute the following command


Observe the -c switch in the command, it tells wget to resume the previously interrupted download.

Extract Contents

After the downloading is finished, extract the tar package into /opt directory.




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

You need root password to run the following command.

Start the Server

If the above command executed with no errors, then, the server is correctly installed. Now to start the server, issue the following the command
1sudo /opt/lampp/lampp start
Point to note, xampp under linux is called lampp.
To check if the server is running open any web browser and type http://localhost in the address bar. You should see the following welcome screen.

XAMPP Splash Screen

Shutdown the Server

If you need to shut down the server, run the following command in the terminal

sudo /opt/lampp/lampp stop

Adding Custom .html pages

Ok, you got server up and running, but where should you put your html files? By default Xampp (Apache) expects all your website related files inside /opt/lampp/htdocs folder. Let us create a test page, test.html, with the following contents,

    My Test Page

</pre>

<h3>This is a test page</h3>

<pre>
Now if you try to save the file in /opt/lampp/htdocs/ directory, you will get an error because of authentication problem. This is because, currently only root has access to /opt/lampp/htdocs/ directory

Authentication Issue

The following commands solves the authentication issues,

sudo adduser USERNAME www-data

sudo chown -R USERNAME:www-data /opt/lampp/htdocs

sudo chmod -R g+rw /opt/lampp/htdoc
Replace USERNAME with your username. What the above commands actually does is
  1. It adds you (User) to www-data (Group)
  2. Changes the ownership of the /opt/lampp/htdocs directory so that you will be the owner.
  3. Issue read+write permissions to the group www-data
Now, you can add the file, test.html, to /opt/lampp/htdocs folder. If everything is done correctly, you can view the file from browser by clicking this link http://localhost/test.html.

Create symbolic link [optional]

To make things simple, you can create a link in your home folder that points to /opt/lampp/htdocs folder

sudo ln -s /opt/lampp/htdocs /home/USERNAME/htdocs
So that’s it for now. In the next post, I will tell you how to host multiple websites in your local server…

No comments:

Post a Comment