LAMP made easy with XAMPP

79

Author: Paul Virijevich

The LAMP (Linux, Apache, MySQL, PHP/Perl) software stack is emerging as a popular and cost-effective Web development platform. This is understandable given that it comprises a free operating system, Web server, database, and scripting language. However, a problem with having a number of separate open source components is integration. The XAMPP project aims to eliminate this problem. With XAMPP, there is no reason for developers to skip over an open source solution when considering Web development platforms.

The XAMPP download includes more than just Apache, MySQL, PHP, and Perl. It also includes a number of related open source packages. Included and integrated are OpenSSL, PEAR, phpMyAdmin, ProFTPD, and Webalizer.

Although this article focuses on the Linux version, XAMPP runs on Windows too, and beta versions for Apple’s Mac OS X and Sun’s Solaris are also available. XAMPP has been officially tested on SUSE, Red Hat, Mandriva, and Debian. That does not mean, however, that it runs only on those distributions; it should run on any modern Linux distribution.

To install XAMPP, issue the command:

tar xvfz xampp-linux-1.4.13.tar.gz -C/opt

That’s it; XAMPP is installed (in/opt/lampp) and ready to go. Uninstalling is just as simple. Just delete the/opt/lampp directory to remove all traces of XAMPP from your system.

XAMPP places a startup script by the name of lampp in the/opt/lampp directory. This script starts, stops, reloads, and checks the status of XAMPP. For example, consider the command:

/opt/lampp/lampp start

This starts the core XAMPP services of Apache (with PHP support), MySQL, and ProFTPD. To see the other options you can pass to XAMPP run the script with the -- help option. Most of the options are self-explanatory, but let’s take a look at two that can affect your site’s performance and security.

The php4 option makes switching from PHP5 (the default) to PHP4 easy. Why downgrade? Some applications designed with PHP4 may experience compatibility problems with PHP5. I encountered such a problem with osCommerce, the popular open source shopping cart. Some of its pages would not display properly with PHP5 due to a change in how a variable was handled. With XAMPP, I could have saved myself a lot of trouble and quickly switched from PHP5 to PHP4 instead of having to modify variables in the PHP code.

If you’re using XAMPP in a production environment, make sure you use the security option. This will prompt you to password-protect the XAMPP pages, restrict network access to MySQL, set a password for the MySQL user for phpMyAdmin, create a root MySQL password, and change the ProFTPD password from the default of “lampp.” Do not run XAMPP in a production environment without making these changes, or your server will have more holes in it than a piece of Swiss cheese.

Accessing the server at http://localhost brings up XAMPP’s administrative page. The frame on the left side of the page is divided into three sections. The first is XAMPP-specific. From here, you can check on the status of the services that XAMPP controls, verify your security settings, read XAMPP’s documentation, and see a list of all of the programs installed by XAMPP.

The demo section contains seven sample programs that utilize XAMPP’s components. These simple programs are not intended to showcase the power of a LAMP platform. Their purpose is simply to verify that the various components are working together correctly. Four of the demos have source code links that provide the PHP code that they use. They can give anyone with minimal PHP experience a quick overview of its syntax.

Finally, in the tools section, you can manage MySQL and SQLite with phpMyAdmin and phpSQLiteAdmin respectively, two Web-based front ends for database management. Their integration makes XAMPP competitive with proprietary Web development environments, because they eliminate the need for a dedicated SQL expert to perform command-line database administration.

The last tool included is Webalizer, a speedy Web server log file analysis program written in C. You can customize its output by editing the file webalizer.conf, located in the etc directory of your XAMPP installation.

This brings us to an important point about XAMPP. Even though XAMPP provides an integrated LAMP stack, you still have to edit configuration files to customize its components. As with Webalizer, these are all located in the etc directory. If you have little prior experience working with Linux or Unix, relax. This need not be a showstopper. The configuration files are well-documented, so you can be up to speed in no time.

Consider XAMPP for your next Web development project. By being distribution-independent, it takes the headache out of making sure that all of your servers are running the same distribution with the same versions of the LAMP stack. XAMPP makes it easy to use LAMP for a production or development platform.

Category:

  • Web Development