Sunday, September 30, 2012

Dual-Booting XAMPP in Windows XP and Ubuntu 10.04.1

Goal: Make a web server that is available from my desktop at work no matter which OS is currently being used (dual-booting xampp in windows xp and ubuntu). The end result should be that the MYSQL database is shared and the web pages are visible as long as the computer is up and running at work.

Reason: Wanted to make an internal website here at the University for showing current research items and publications online.





MATERIALS:


- 4GB Memory Stick. (I used a Buffalo TurboUSB 4GB, but bigger might be better)

- Logitec (not Logitech, but Logitec) USB 2.0 PCI Board with 1 internal USB port and 3 external ports.  (for the record only - this is the type I currently have and I mention it because it has 1 internal port where the USB stick will live once we are ready)

- Apache Friends' XAMPP server packages for Windows and Linux. -

- EXT2 file system support for Windows XP - I chose this because NTFS/FAT32 file systems don't support ownership and permissions in the same way as Linux does.

- Windows XP Professional and Ubuntu 10.04.1 Desktop installed via the WUBI installer.




PROCEDURE: Note: OS/Dual Boot installations are not discussed here! Just web server stuff!


STEP 1: FROM XP

  • Boot your PC into Windows XP.

  • Download EXT2 file system support for Windows XP and install.

  • Enable support for writing to EXT2, but don't enable the "force write to EXT3" option.  I didn't find I needed it.

Note: Be sure to allow EXT2 support to run at boot time (i.e. install the service when it asks you to do so)

STEP 2: FROM LINUX

  • Boot your PC into Ubuntu 10.04.1 and plug your USB memory stick into a port.

  • Format the memory stick with the EXT2 file system.  Use your favorite partition editor.  I used GPARTED.

Note: By default, Ubuntu auto-mounts the USB stick.  You'll have to unmount it before you can format it.

STEP 3: FROM XP

  • Reboot your PC into Windows XP.

  • Test your EXT2 memory stick by trying to click on it from "My Computer".

  • If the EXT2 extensions are installed properly and the drive was formatted properly, you should be able to see a "lost+found" directory.

  • If you can't access the USB stick, go back to the EXT2 driver settings and check to make sure the support is loaded and running.

  • If the EXT2 driver seems ok, try repartitioning the USB stick with EXT2 again (from Linux, step 2).

Note: For convenience, I renamed the USB stick to "XAMPP" from the My Computer window.  Slow-two-click on the drive, and you can rename it.  It makes for a cleaner auto-mount point in Linux.

STEP 4: FROM XP (still)

  • Download the Windows EXE from Apache Friends and install the program.

  • Make sure you select the USB stick as the install destination.

  • Notice that the "xampp" directory is created on the stick.

  • When the install finishes, XAMPP will ask some configuration questions.

  • If you want to have the stick auto start when you boot, make sure you USE DRIVE LETTERS in your install and allow the program to make icons and start menu items.

Note: Don't worry if you choose incorrectly or your drive letters change by mistake.  The program includes a reconfiguration utility which came in handy when it happened to me.


  • Test your installation by launching Apache and MySql from the XAMPP console.

  • Access your XAMPP in a browser using "localhost" or your URL if you have one.

  • If you see the XAMPP front page, you are done with the Windows XP setup.

STEP 5: FROM LINUX

  • Reboot your PC into Ubuntu 10.04.1.

  • Download the XAMPP for Linux from Apache Friends to the memory stick.

  • Un-archive the file on the stick.  Notice the "lampp" directory gets created.

Note: Ubuntu has a graphical un-archive tool which launches when you two-click the archive file.  Or you can use the command line from the directory containing the archive file as follows:

tar -xvf xampp-linux-1.7.3a.tar.gz

STEP 6: FROM LINUX (still)

  • Open a terminal and create a symbolic link to the USB stick lampp directory from the /opt directory.

sudo ln -s /media/XAMPP/lampp /opt/lampp


  • Test your Linux XAMPP installation by running the following command:

sudo /opt/lampp/lampp start


  • Now view the XAMPP home page using your browser and navigating to "localhost".

  • If you see the XAMPP pages, you've got it working.

  • Now stop the server before the next section:

sudo /opt/lampp/lampp stop





MYSQL DATABASE SHARING:


STEP 7: FROM LINUX (still)
Note: The rest is done from the Ubuntu side of things.  The Windows XP version of the MYSQL Database will be used and the Linux version will be left alone untouched.


  • Open a terminal and change directory to /opt/lampp/var

cd /opt/lampp/var


  • Rename the "mysql" directory to "mysqlDONTUSE"

sudo mv mysql mysqlDONTUSE


  • Create a symbolic link relative path to the Windows XP MYSQL directory.

sudo ln -s ../../xampp/mysql/data   ./mysql


  • Now restart the XAMPP server for Linux.

sudo /opt/lampp/lampp start


  • Check your pages again to make sure you can see them.

  • Troubleshoot as needed.





MISCELLANEOUS:


If you ran the security setup functions in the Windows XAMPP program before installing the Linux XAMPP stuff, you may have to make some additional tweaks.

PMA CONTROL USER PASSWORD: FROM LINUX (still)

Edit the config.inc.php file in BOTH Windows AND Linux installations of XAMPP.
Windows file: /media/XAMPP/xampp/phpMyAdmin/config.inc.php
Linux file: /media/XAMPP/lampp/phpmyadmin/config.inc.php

Make sure the password for PMA (controluser/controlpass) the same by copying FROM the Windows TO the Linux versions of the file.

HTDOCS REDIRECTION/LINKING: FROM LINUX (still)
Note: The "xampp" directories under "htdocs" for both the Windows XAMPP and the Linux XAMPP must remain unique since they have different options on them and the programs are different.

However, you can redirect the index.php from it's default of "xampp" to another location such as "wordpress" if you have wordpress installed. In this case, only 1 "wordpress" directory should exist and I recommend putting it under the Windows XAMPP "htdocs" directory and linking to it from the Linux XAMPP htdocs.




LINUX AUTOSTART:


Note: Auto-starting XAMPP in Linux is tricky because the USB stick won't mount until after the user logs in to the system. By then, all the scripts in "/etc/init.d" have run their course.


  • However, I worked around this by writing a simple shell script which I added to "/etc/init.d". Here is the code for that:

#!/bin/bash
# XAMPP for Linux shell script. (lamppstart)
# For launching XAMPP on a USB stick that isn't immediately mounted.
while [ ! -f /opt/lampp/lampp ]
do
echo "Waiting for XAMPP mountpoint to run /opt/lampp/lampp $@"
sleep 5
done
/opt/lampp/lampp $@


  • Don't forget to make the script executable:

$ sudo chmod 755 /etc/init.d/lamppstart


  • And don't forget to add it to the proper run levels during boot

$ sudo update-rc.d /etc/init.d/lamppstart defaults

No comments:

Post a Comment