Install Ubuntu/Debian LAMP Server


LAMP is essentially a server that runs Linux, Apache, MySQL and Php/Perl and is more commonly known as a LAMP server. This wiki item will provide detailed instructions on setting LAMP up and once completed you will have a LAMP server that runs:

  • Apache 2 – Linux Web server
  • MySQL 5 – MySQL Database Server
  • PHP5 – PHP Scripting Language
  • phpMyAdmin – Web-based database admin software.


  • A Debian Etch base installation – Installation HOWTO here.
  • At least 256MB of RAM installed on your machine.
  • An understanding of the “apt-get” command.


Before proceeding to install, update the necessary packages with Debian with this command.

apt-get update
apt-get upgrade

Installing Apache 2 + PHP5

To install Apache 2 and PHP5, just run the following in a Linux shell.

apt-get install apache2 php5 libapache2-mod-php5

Your Apache 2 configuration file is located at: /etc/apache2/apache2.conf and your web folder is /var/www

Let’s check that PHP5 was installed correctly. Run the following command to open up the vim editor and create a new php page called test.php:

vim /var/www/apache2-default/test.php

With this page opened insert the following code into vim:

<?php phpinfo(); ?>

You can now save the file.

Point your browser to and this should show all your PHP5 configuration and default settings.

Installing MySQL 5 Database Server

Installing the MySQL database server is necessary if you intend on running a database driven web site. The following commands will install MySQL 5 server and MySQL 5 client.

apt-get install mysql-server mysql-client php5-mysql

The configuration file of MySQL is located at: /etc/mysql/my.cnf

Creating users to use MySQL and Changing Root Password

By default MySQL creates a user as root and runs with no password which is a high security risk. You will need to change the root password immediately.

To change Root Password:

mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';

You must never use your root account and password when running databases. The root account is a privileged account which should only be used for admin procedures. You will need to create a separate user account to connect to your MySQL databases from a PHP script. You can add users to a MySQL database by using a control panel like phpMyAdmin to easily create or assign database permissions for users.

phpMyAdmin Installation

phpMyAdmin is a nice web based database management and administration software and easy to install and configure under apache. Managing databases with tables couldnt be much simpler by using phpmyadmin.

All you need to do is:

apt-get install phpmyadmin

The phpMyAdmin configuration file is located at: /etc/phpmyadmin

To have access to phpMyAdmin on your website (i.e. ) all you need to do is include the following line in /etc/apache2/apache2.conf:

Include /etc/phpmyadmin/apache.conf

Now restart Apache:

/etc/init.d/apache2 restart

Point your browser to: and you’re ready to go.

That’s it! MySQL and phpMyAdmin are ready. Log in with your MySQL root account and password and create users to connect to the databases from your PHP script.

The really quick way of doing this

The above is broken into step by step examples to give you a detailed understanding of what each step does. However, you can install the LAMP server running only two commands. First run:

apt-get update

And then run:

apt-get install apache2 php5 libapache2-mod-php5 mysql-server mysql-client php5-mysql phpmyadmin
Explore posts in the same categories: Ubuntu & Debian, Ubuntu/Debian

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s

%d blogger menyukai ini: