Android LAMP (Linux,Apache,MySQL,PHP)

I recently purchased a Samsung Galaxy Tab (GT-6200) and quickly decided I needed to be able to do some web development and site testing when offline. I was happy to find that the process of getting a LAMP stack up and running can be relatively straightforward. In this post I’ll cover getting Debian up and running. In my next I will cover Apache, MySQL, and PHP. After that I will cover setting up an graphical environment with lxde, GIMP, and Inkscape.

So, lets get started:

1. Root your system.

This process is different for every device. I followed the tutorial HERE, which involved downloading a file to my external sdcard and rebooting into debug mode. Samsung did something strange with their filesystem by making “/mnt/sdcard” the internal tablet memory. To root the GT-6200, the file must be in “/mnt/sdcard/extStorages/SdCard”.

2. Install the following packages in Android:

Superuser, Android Terminal Emulator, and Linux Installer

I also found the following programs helpful for various development activities unrelated to getting your server up and running:
AndFTP, 920 Text Editor, ConnectBot, ColorHex, Hacker’s Keyboard, FireFox, Opera Mobile, and View Web Source

3. Configure Linux Installer.

You can ignore any /proc/config.gz errors when you open the program. If you get superuser/root errors, make sure you have rooted your phone and installed the Superuser Android app and restart the Linux Installer app. The default filesystem is only 500MiB, which is plenty for a terminal-based web server, but you will want to make this larger if you plan on running a desktop environment (2+GiB). I experienced bugs when trying to rename the chroot start script to something other than linuxchroot. If for some reason you dont have space for the Linux.loop file in the default location and the linuxchroot script is not updating properly, you can edit it by running:

cat $(which linuxchroot)

The output will tell you the location of the .sh file to edit to fix any errors.

The only other setting you might want to change is the distribution and branch, I chose Debian for distribution and Testing for branch (Stable could be a better choice if you don’t mind having older program versions). I also checked all boxes under “Package software configuration”.

4. Begin the installation.

Ensure that you have the time and battery charge to complete the entire installation process as any interruption could have unpredictable results. The installation should be straightforward:
-Click “Create target loop”, then “Format target loop”, then “Mount loop”. You should be able to safely override any Chroot warning concerning removeable storage as long as you dont try to remove the card the loop file is on or access it via USB while it is mounted.
-Click “Install distribution in LOOP”. At this point if you switch to another app for more than a few minutes, your installation could be incomplete. Have some patience and keep the installer active. If the install does hang, exit the Linux Installer app and restart it, this time SKIPPING the “Create..”. and “Format…” options and go directly to “Mount loop”and select the “Install…” option again. Once the install completes, click “Update linuxchroot script in Android”

5. Start Linux.

Open the Terminal emulator and type:


6. Update your system and install desired programs.


apt-get update

apt-get upgrade

To shutdown the chroot environment, run:


To run commands on startup and shutdown of your system, you will need to edit the following files inside your chroot environment:



4 thoughts on “Android LAMP (Linux,Apache,MySQL,PHP)”

  1. Hi, I have done the same actions but mysql cannot start because it can open a socket. Can you provide any workaround for that ?

    1. Did you try what I posted in the next article?

      If your experience mirrors mine, mysql-server will install with an error related to the MySQL socket being unable to start. If that is the case, do the following:
      nano /etc/mysql/my.cnf




  2. Hi I tried to follow your instructions.

    But i got below at apt get upgrade.
    Can you help to take a look?

    root@Galoula-ARMEL:/# apt-get upgrade
    Reading package lists… Done
    Building dependency tree… Done
    The following packages will be upgraded:
    1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0 B/2344 kB of archives.
    After this operation, 4096 B of additional disk space will be used.
    Do you want to continue [Y/n]? y
    dpkg: warning: ‘ldconfig’ not found in PATH or not executable.
    dpkg: warning: ‘start-stop-daemon’ not found in PATH or not executable.
    dpkg: 2 expected programs not found in PATH or not executable.
    NB: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
    E: Sub-process /usr/bin/dpkg returned an error code (2)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.