We wrote about the XAMPP project in this article. This project is perfect for maintaining a cross platform dev environment for an application we are currently working on. Most of the work is done on OS X, but we also do some work on GNU/Linux. Further, the target audience for this may very well use XAMPP to run the application, since it is not a public application. It will run on a specific user’s machine. Our GNU/Linux box, for instance, already has Apache and MySQL on it;however, it is very easy to isolate the database and configuration of PHP, as well as maintain consistent operation between platforms using XAMPP. We initially developed the application on OS X. To get the app up and running on GNU/Linux, we first need to install XAMPP:
[root@srv-1 usr-1]# ls xamp* xampp-linux-1.4.16.tar.gz [root@srv-1 usr-1]# ls /opt [root@srv-1 usr-1]# tar -xzf xampp-linux-1.4.16.tar.gz -C /opt [root@srv-1 usr-1]# /opt/lampp/lampp start Starting XAMPP for Linux 1.4.16... XAMPP: Starting Apache with SSL (and PHP5)... XAMPP: Starting MySQL... XAMPP: Starting ProFTPD... XAMPP for Linux started. |
Really, before you do anything else, secure it. Don’t even dink around on the web page:
[root@srv-1 usr-1]# /opt/lampp/lampp security XAMPP: Quick security check... XAMPP: Your XAMPP pages are NOT secured by a password. XAMPP: Do you want to set a password? [yes] XAMPP: Password: XAMPP: Password (again): XAMPP: Password protection active. Please use 'lampp' as user name! XAMPP: MySQL is accessable via network. XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] XAMPP: Turned off. XAMPP: Stopping MySQL... XAMPP: Starting MySQL... XAMPP: The MySQL/phpMyAdmin user pma has no password set!!! XAMPP: Do you want to set a password? [yes] XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL pma password. XAMPP: Setting phpMyAdmin's pma password to the new one. XAMPP: MySQL has no root passwort set!!! XAMPP: Do you want to set a password? [yes] XAMPP: Write the password somewhere down to make sure you won't forget it!!! XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL root password. XAMPP: Change phpMyAdmin's authentication method. XAMPP: The FTP password is still set to 'lampp'. XAMPP: Do you want to change the password? [yes] XAMPP: Password: XAMPP: Password (again): XAMPP: Reload ProFTPD... XAMPP: Done. [root@srv-1 usr-1]# |
We need to transfer our PHP and HTML files:
[root@srv-1 htdocs]# cp /home/usr-1/htdocs/*.php ./ [root@srv-1 htdocs]# cp /home/usr-1/htdocs/*.html ./ [root@srv-1 htdocs]# pwd /opt/lampp/htdocs [root@srv-1 lampp]# cp /home/usr-1/config.php ./ [root@srv-1 lampp]# pwd /opt/lampp [root@srv-1 lampp]# |
Now, the paths are embedded in the system, so you need to make sure that you use the correct binary. Also, before you go restoring any databases, shut down, if possible, any other instances of MySQL. As an added precaution, use different passwords for your databases. Of course, unless you change port numbers, you can’t run the XAMPP stuff concurrently with any other MySQL and/or Apache services. Remember, XAMPP is not for production. It fits our needs perfectly, though. Here is how we back up our database on the OS X side:
srv-5:/Applications/xampp/xamppfiles/bin usr4$ pwd /Applications/xampp/xamppfiles/bin $ ./mysqldump --all-databases -u root -p | bzip2 -c > ~/databasebackup.sql.bz2 Enter password: srv-5:/Applications/xampp/xamppfiles/bin usr4$ |
On the GNU/Linux side, let’s restore:
[usr-1@srv-1 ~]$ ls data*.bz2 databasebackup.sql.bz2 [usr-1@srv-1 ~]$ bzip2 -d databasebackup.sql.bz2 [usr-1@srv-1 ~]$ [usr-1@srv-1 ~]$ /opt/lampp/bin/mysql -p -u root < databasebackup.sql Enter password: [usr-1@srv-1 ~]$ |
That is all it takes to mirror our dev environment between platforms. I believe that, technically, the versions of software are different between the current OS X and GNU/Linux distributions of XAMPP; however, they are close enough that our PHP app works on both platforms just fine. A big tip o the hat and a hug to the XAMPP crew for a fabulous project. It sure makes things easier.