Android LAMP (Linux,Apache,MySQL,PHP) Part Two

Now that you have Linux up and running, you can move on to the relatively straightforward pricess of getting Apache, MySql, and PHP running. Open your terminal emulator and run linuxchroot to get your Linux environment up and running.  

1. Update your system.

apt-get update

apt-get upgrade

2. Install and configure MySQL

apt-get install mysql-server mysql-client

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




3. Install Apache2

apt-get install apache2 apache2-doc

a2enmod userdir

service apache2 restart

4. Install PHP and, optionally PHPmyAdmin

apt-get install php5 php5-mysql libapache2-mod-php5

apt-get install phpmyadmin

5. Configure Apache and MySQL to start everytime you start linux

nano /etc/
service mysql start

service apache2 start

6. Configure shutdown script

nano /etc/
service apache2 stop

service mysql stop

At this point you should be up and running. Opening the browser on your android device and going to http://localhost/ or will take you to your internal LAMP server anytime your linuxchroot envirnoment is running.

18 thoughts on “Android LAMP (Linux,Apache,MySQL,PHP) Part Two”

  1. all done fine…but still can’t access or localhost (not a permission problem). any solutions?

    1. What happens when you run:

      You should also check that the apache service is running within the linux installation by running:
      ps -A

      If apache is not running for some reason, check in /var/log

      1. when i ping it respond. when i start the apache server it writing [OK] but i can’t find the process with ps -a so i opened the error.log and it says “function not implemented:couldn’t create accept lock”
        Thanks anyway for your reply…Finally i know what’s the problem and i’ll try to find an issue 🙂

      2. I find this Tutorial on
        it works with my device!

        This bug is not limited to mod_rewrite; it affects all lock files.

        Is it perhaps a kernel 2.4 vs 2.6 issue?

        I’m running sid on a leased uml running 2.4.21-7um.

        The function that dies is in:


        where it calls:

        rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname,
        ap_accept_lock_mech, _pconf);

        that function is defined in:


        and that ends up choosing one of these:

        new_mutex->inter_meth = &apr_proc_mutex_unix_fcntl_methods;
        new_mutex->inter_meth = &apr_proc_mutex_unix_flock_methods;
        new_mutex->inter_meth = &apr_proc_mutex_unix_sysv_methods;
        new_mutex->inter_meth = &apr_proc_mutex_unix_posix_methods;
        new_mutex->inter_meth = &apr_proc_mutex_unix_proc_pthread_methods;

        I cannot tell from the strace which it is selecting.

        But adding:

        AcceptMutex fcntl

        in the section solved the problem.

  2. Hi, i have a broken i9100, and i want to use it as a lamp server for my php programing, the problem is i dont know how to configure the device respond to requests on port 80 from external source like lan, the ssh is working but http not any ideas?

    1. Do you have your http server up and running and accessible via localhost? Other ideas you could consider:
      Is your wifi going to sleep when the device is inactive?
      If you can access the http server locally, but not remotely, consider setting up an ssh tunnel for your http server if all else fails. This would be a convoluted technique for something that should work if you have the http server responding to local requests and are able to contact the ip address of your android device from another device on the network.

  3. Really cool that you can run all this on an android.. got this all happening on my note 8.0!
    Thanks alot for writing this tute..

    One question.. how do I edit files in the loop? Using a text editor in android itself?



    1. Glad I could help. Normally, you are going to want to edit files in the loop using the linux terminal and a command such as ‘nano’. Alternatively, you could run an ftp server(or other network file sharing service) on the linux installation.

      1. Hey mate.. thx for getting back… and yup I went ahead and installed proftpd to do just what u suggest.. should be an elegant setup.. but as of yet I cant get proftpd to play.. so far getting the following warning

        ProFTPD warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.

        Haven’t found a solution as of yet..



  4. Openvpn install:

    If you nead also like me openvpn and it don’ t work out of the box run

    mknod /dev/net/tap c 10 200
    mknod /dev/net/tun c 10 200
    chmod 600 /dev/net/tap
    chmod 600 /dev/net/tun

    and than

    service openvpn restart

    Have fun!


  5. Hey I am very thankful to tutorials like yours since I am a total novice and I don’t plan on using this for anything more than a hobby.
    I followed the different steps as you mentioned and I also encountered the issue during mysql installation which it seems was resolved using your indications, nevertheless when I installed apache2 another issue popped up

    root@Galoula-ARMEL:/# service apache2 restart
    [….] Restarting web server: apache2(98)Address already in use: make_sock: could not bind to address [::]:80
    (98)Address already in use: make_sock: could not bind to address
    no listening sockets available, shutting down
    Unable to open logs
    Action ‘start’ failed.
    The Apache error log may have more information.

    Do you by any chance know the solution to this?

    Whether it is a yes or a no, thank you anyway.

    1. Ok I think I found the solution

      1) open /etc/apache2/ports.conf with any text editor and change the value of the entry “Listen 80″ to the desired port”

      eg Listen 8080

      2) Change the entry for to the same port no u gave in the ports.conf file in /etc/apache2/sites-enabled/000-default

      it was posted by user rahul in

      i had to change sites/enabled by sites-enabled


  6. I am writting this just in case someone encounters the same problems I did.

    You may think apache2 is running because it says ok when started but as Daniel Petty says it has to show up when you run ps -A otherwise it is not.
    In that case go to check the error logs in debian are stored in var/log/apache2/error.log you will probably see something like:

    (38)Function not implemented: Couldn’t create accept lock

    Then as it has already been said here follow the solution proposed in

    But in my case you have to go to etc/apache2/apache2.conf and edit the document, look for the entry and add AcceptMutex fcntl

    Restart and check if everything works properly.

Leave a Reply

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