Monday, April 22, 2013

Installing Apache2 + PHP5 + MySQL (On Ubuntu 12.04 LTS)


LAMP on Ubuntu

1. Installing MySQL
apt-get install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on.


2. Installing Apache2
apt-get install apache2

Now direct your browser to http://ServerIP, and you should see the Apache2 placeholder page (It works!):



3. Installing PHP5
apt-get install php5 libapache2-mod-php5 php5-mysql 
/etc/init.d/apache2 restart


4. Testing PHP5 / Getting Details About Your PHP5 Installation
The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php





<?php
  phpinfo();
?>


Now we call that file in a browser (e.g. http://ServerIP/info.php):