Friday, December 10, 2010

LAMP Server Stack

Setting up a Linux Apache MySQL PHP (LAMP) server requires a few commands to get you up and running.

If you run Ubuntu or Debain - this is how I got started (Ubuntu 10.04) ; Open a terminal and run:
sudo apt-get install php5 php5-mysql mysql-server mysql-client mysql-query-browser apache2

As you can see from the list above, this command will install the following programs:
  • PHP ver 5
  • PHP MySQL Module
  • MySQL Server
  • MySQL Client
  • MySQL Query Browser GUI
  • Apache 2 Web server

During the MySQL install you will be asked to create a password for the MySQL root user. Remember this username/password.


Verify Apache is Operational

When the install finishes; Browse to http://localhost/ and look for the infamous  

"It Works!"

message. If you see this, Apache is up and running properly.


Verify PHP is Operational

Build yourself a file called test.php with the following code in it:
<?
phpinfo();
?>
Save the file test.php in /var/www/ - this is the default local directory where Apache serves up your web documents.

Open a browser and enter the address: http://localhost/test.php

This should display a long page containing version information and current configuration of PHP.

This means that the file was executed properly and PHP is working.


Verify MySQL Server is Operational

From the terminal type:
mysql -u root -p
This command runs mysql as user (-u) root with a password of...(-p) You will be prompted to enter a password. This is the root MySQL password created when installing MySQL.

If you correctly enter the password you will be taken to the mysql> command prompt.

MySQL is working. Type: quit

Congratulations, you now have a LAMP server stack at your service!

Enjoy. 

No comments:

Post a Comment