LAMP stands for Linux, Apache, MySQL and PHP.

Installing on Debian is easy. Simply follow the following steps. We will be installing MySql, followed by Apache, PHP and Phpmyadmin.

First update the apt repo:

apt-get update

 Install MySQL:

apt-get install mysql-server mysql-client

At this point, you will be prompted to install mysql root password three times.


Install Apache2:

apt-get install apache2 apache2-doc

To run content from your user directory, do the following:

Enable the module:

a2enmod userdir
/etc/init.d/apache2 restart

Now edit /etc/apache2/mods-enabled/userdir.conf

emacs /etc/apache2/mods-enabled/userdir.conf

Make sure that it looks like this:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        <Directory /home/*/public_html>
                AllowOverride All
                Options MultiViews Indexes SymLinksIfOwnerMatch
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all

Note that you will have to delete parts of a few lines. Or you can exec the following:

sudo cat /etc/apache2/mods-enabled/userdir.conf | sed 's/AllowOverride FileInfo.*/AllowOverride All/' >test.txt
sudo mv test.txt /etc/apache2/mods-enabled/userdir.conf
sudo cat /etc/apache2/mods-enabled/userdir.conf | sed 's/Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec.*/Options MultiViews Indexes SymLinksIfOwnerMatch/' >test.txt
sudo mv test.txt /etc/apache2/mods-enabled/userdir.conf

which does the edit automatically.

Now as normal user, create a public_html folder:

mkdir /home/$USER/public_html

Now change group and restart the web server:

chgrp www-data /home/$USER/public_html
service apache2 restart

 Install PHP:

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

To allow running php scripts from user directories, Configure the file  /etc/apache2/mods-available/php5.conf :

emacs /etc/apache2/mods-available/php5.conf
<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_value engine Off
    #    </Directory>

As mentioned in the instructions in this file, you need to comment out the later part.

Check that everything works:

Check that public_html can be accessed from localhost.

Create a file index.html in ~/public_html:


Test succeeded


Now, type in the browser address bar:


If all goes well, you should get the success message.

Now test php. Create the file ~/public_html/phptest.php:


Now restart the web server

sudo service apache2 restart

and enter the following address in the browser:


Of course you have to replace your username for droidzone.

If it gives an error message or the file browser is displayed instead of a webpage, recheck the instructions. If they were correct, in most cases, you need to just restart apache2 service.

Optionally, you can install Perl or Python:

Install Perl:

apt-get install perl libapache2-mod-perl2

Install Python:

apt-get install python libapache2-mod-python

Install Phpmyadmin:

apt-get install phpmyadmin

When prompted, select Apache2 as the web server to be reconfigured automatically.

Also, choose Yes when asked to create a default database.

Configure a passwordless login with phpmyadmin (Not recommended, Optional):

cat /etc/phpmyadmin/ | grep -ni --color 'AllowNoPassword'
65:    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
94:// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

Now change the Line #65 (the first hit) to remove the comment tag at the beginning.

You can login to phpmyadmin at http://localhost/phpmyadmin

Note that the username it automatically inputs is your username. However such a user doesnt exist. You can login as root.

Additional Info:

Enabling PHP Debugging:

sudo emacs /etc/php5/apache2/php.ini

and turn on display_errors.

If you dont know what line it is on:

grep 'display_errors' /etc/php5/apache2/php.ini

to find out the line:

[[email protected] ~]$ grep 'display_errors' /etc/php5/apache2/php.ini
99:; display_errors
534:display_errors = Off
537:; separately from display_errors. PHP's default behavior is to suppress those

You can even execute the following command to make it write the proper value for debugging:

cat /etc/php5/apache2/php.ini | sed 's/display_errors = Off/display_errors = On/' > test ; mv test /etc/php5/apache2/php.ini



  1. Debian Wiki