[gss-content-box color=”red”]Article license. | Level: Beginner | Category: Web Development[/gss-content-box]
A local development environment is important in order to be able to test, configure and tweak all the different web projects, either designing a front-end or developing for the back-end. The local development is a required part of any designer or developer work-flow in order to have a success full deployment.
XAMPP for Linux is a quick way to have in one package all we need to have such a local development environment.
The name XAMPP comes from the below components:
X – generic name shows the multi-platform capability of the software package (Linux, Windows, Mac etc.)
Apache HTTP Server
What are the steps?
Step 1 – we get the installation kit from the XAMPP website
I recommend using the version 1.8.0. The latest releases have issues with the installation package from Bitnami on some Linux distributions (e.g. Elementary OS). You can still try and use the latest release; the team behind “apachefriends” tried to make the installation graphical and “easier” but they introduced new issues instead. They may be fixed in the meantime but for the purpose of this article and from my point of view the 1.8.0 is the most suitable to be used.
You can save the installation kit by accessing the following link from Sourceforge – http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.8.0/.
The kit has 84.7 MB so depending on your Internet connection it will take a while to save. The installation kit comes as a tar.gz archive – “xampp-linux-1.8.0.tar.gz”.
These are the main components in XAMPP version 1.8.0:
[one-half first] Apache 2.4.2
MySQL 5.5.25aPHP 5.4.4 Perl 5.14.2 ProFTPD 1.3.4a phpMyAdmin 3.5.2 OpenSSL 1.0.1c GD 2.0.1 Freetype 2.1.7 libjpeg 6b libpng 1.2.12 gdbm 1.8.0 zlib 1.2.3 expat 1.95.2 Sablotron 1.0 libxml 2.7.6 libxslt 1.1.26 Ming 0.4.3 Webalizer 2.21-02
[one-half] pdf class 009e
ncurses 5.7 mod_perl 2.0.5 FreeTDS 0.63 gettext 0.17 IMAP C-Client 2007e OpenLDAP (client) 2.4.21 mhash library 0.8.18 mcrypt library 2.5.7 cURL 7.21.0 SQLite 2.8.17 (for PHP4 + PHP5) liSQLite 3.6.16 (for PHP5 PDO SQLite) libapreq 2.12 eAccelerator 0.9.6.1 FPDF 1.6 bzip2 (library) 1.0.5 PBXT 1.0.11-6-pre-ga PBMS 0.5.15 (but disabled) PBMSlib 0.5.15 ICU4C Library 4.2.1 APR 1.4.6 APR-utils 1.4.1
Step 2 – install the XAMPP kit
We will need to use the terminal to install XAMPP; you need to open the folder where you save the installation kit in order to perform the following commands.
These are generic commands that work in any Linux distributions.
[gss-content-box color=”red”]Note: the “sudo” part asks for administrative rights for the regular user so that the XAMPP kit can be installed/copied in the primary folder structure (“-C”) in the “/opt” folder. The rest of the command – “tar xvfz” starts the archiver and tells it to dezarchive the kit.[/gss-content-box]
sudo tar xvfz xampp-linux-1.8.0.tar.gz -C /opt
After running the above command, the XAMPP kit is installed as you can see from the below screenshot in “/opt/lampp”.
Step 3 – we start XAMPP
Again we will use the terminal; run the following command to access the XAMPP folder.
In order to start XAMPP you will need to input the following command; your personal password will be requested.
sudo ./lampp start
XAMPP will start the Apache, MySQL and ProFTPD servers.
Command to stop XAMPP:
sudo ./lampp stop
[gss-content-box color=”red”]Note:if you run all these commands in the same terminal in which you started XAMPP the Linux system will not ask you for your personal password again.[/gss-content-box]
In order to confirm that XAMPP is up and running, we need to open a browser window (for this article I am using Google Chrome; we can use also Firefox or Opera) and use as an address – “localhost”.
The end result should look similar to the below screenshot; you may be presented with an initial screen where you need to select the language and after doing this, you will see the page below.
By accessing the “Status” page we can see the overall status for XAMPP.
Also from the XAMPP start page we can access the phpMyAdmin tool, which allows interaction with the MySQL database server – using a GUI interface.
If you try to access for the first time phpMyAdmin you will get the following error:
Steps to solve the access to phpMyAdmin:
Open a terminal and input the following command in order to access the XAMPP folder:
Run the command:
Midnight Commander is a text based file manager; those of you familiar with MS-DOS period (if any :))maybe you remember the famous – “Norton Commander”. MC is similar and very usefull when we want to have an interface to the command line.
With the help of MC we will access the following path (use arrows key and enter or the mouse):
We will select and edit the file “httpd-xampp.conf” by pressing F4. At the begining of the file we will add the following line to the section
Press F2 to save the change in the file.
Press F10 to exit edit mode in MC and one more time to quit MC.
Next step is to run the security protocol that XAMPP has integrated; run the following commands in the terminal (you can be asked your personal password):
sudo ./lampp security
You will see the following options:
[gss-content-box color=”red”]Note: for the XAMPP pages I will use “no” because I am the only use for this computer and I don’t need to block the access to the XAMPP pages (you can access them in the browser by entering “localhost”).[/gss-content-box]
This is the option that interests us: we need to enter a password for the phpMyAdmin user.
We also need to enter a custom password for the “root” MySQL user.
I am using this information in my WordPress installs; the alternative is to use the above user – “pma” and its password.
Next in line the FTP user and password.
It is recommended to enter a custom password as well for this step.
We stop XAMPP so that the new settings can be taken into consideration; we also need to see if our access issue with phpMyAdmin has been solved or not.
./sudo lampp stop
We access again the graphical interface via the the browser and “voila!” the phpMyAdmin interface is running well and is ready for a project deployment.
Step 4 – we configure the permission level for the “htdocs” folder
The “htdocs” folders in the XAMPP main folder can be used to install all our future web projects, including WordPress installations, Drupal installations etc. The alternative is to setup an “alias” for that folder so that we can use any other folder instead. I will comeback with another article detailing this kind of approach. For the purpose of this article we will go with the standard – “htdocs” folder.
We launch the terminal and run MC:
cd /opt/lampp sudo mc
Select the folder “htdocs” and than from the main menu – File -> Chmod:
We change the permission level for this folder as per the screenshot below:
In the end the “htdocs” folder will have the permission level of 777 which will grant full access to the web server. We can use these kind of permission as we are in a local development environment. The 777 is not recommended on a production server.
Step 5 – We test XAMPP
In order to test XAMPP, we will create a simple HTML file in the “htdocs” folder and we will loaded in the browser by using the below address:
That’s it! We have XAMPP up and running. I will come back with two new articles – one that will be focused on a WordPress installation in XAMPP and another one which will contain advanced tips&tricks for XAMPP – like setting up an “alias”, changing the default PHP settings, etc.