How To Set Up A Ubuntu/Debian LAMP Server

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

Before proceeding to install, update the necessary packages with debian with this command.
apt-get install update

1. Installing Apache + PHP

apt-get install apache2 php5 libapache2-mod-php5

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

To check whether php is installed and running properly, just create a test.php in your /var/www folder with phpinfo() function exactly as shown below.

nano /var/www/test.php

# test.php

<?php phpinfo(); ?>

Point your browser to: http://”ip adress”/test.php

2. Installing MySQL Database Server

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

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

By default mysql creates user as root and runs with no passport. You might need to change the root password.

To change Root Password:

mysql -u root

mysql> USE mysql;

mysql> UPDATE user SET Password=PASSWORD(‘new-password’) WHERE user=’root’;

mysql> FLUSH PRIVILEGES;

3. PhpMyAdmin Installation

apt-get install phpmyadmin

The phpmyadmin configuration file is located at: /etc/phpmyadmin folder.

To set up under Apache 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: http://domain/phpmyadmin

That’s it! MySQL and phpMyAdmin are ready. Log in with your mysql root password and create users to connect to database from your php script.