Aug 29, 2009

LAMP on Ubuntu (Apache MySQL PHP)

LAMP stands for Linux, Apache, MySQL, PHP (or Perl/Pythton)
Ubuntu 9 (Jaunty) now has a command utility called 'tasksel' which displays the packages that can be installed on top of the OS.
Issuing the command in sudo mode will start a GUI based application (similar to old file manager or BIOS setup utility).



Just scroll down to LAMP Server hit the spacebar to select the option and the application will do the rest.



It will ask for MySQL root password in between the installation process.
After the installation process finishes the application will close and the command prompt will reappear.

Checking the install and additional configuratiton


1. As part of LAMP, Apache should be installed in /etc/apache2
2. The start stop script is /usr/sbin/apache2ctl
3. The configuration file is /etc/apache2/apache2.conf
4. The context root is in /var/www and the site configuration is in /etc/apache2/sites-available/default
5. Going to http://localhost/ should now give you the html contents of the index.html file.
In the /var/www directory create a file test.php whose contents are just one line <?phpinfo();?>
6. Going to http://localhost/test.php should yeild a long page listing all the variables and configuration parameters of PHP. If this page comes, then PHP is configured correctly.
7. MySQL should be installed in /usr/bin/mysql
8. We want to check MySQL with phpmyadmin GUI, so lets download & install it. apt-get install phpmyadmin. A screen similar to tasksel will open up and ask a few questions like the password of the root user for MySQL and which server should be configured (apache2) and to create a phpmyadmin user/passwd.
9. Now going to http://localhost/phpmyadmin should open up the GUI admin utility (login with mysql root user)
10. Using this utility create a database, table and insert a row in this table.
11. Now, create a file called data.php in the /var/www/ directory having the following contents.
<html>
<body>
<?php
$db = mysql_connect("localhost", "root","passwd");
mysql_select_db("lamptest",$db);
$result = mysql_query("SELECT * FROM testtable",$db);
printf( "First: %s
\n", mysql_result($result,0,"firstname"));
printf( "Last: %s
\n", mysql_result($result,0,"lastname"));
?>
</body>
</html>

12. The output with data from the table should be displayed appropriately.

So now we have a working Apache server with PHP configured and connected to MySQL (which can be administered from phpmyadmin) all set and ready to rocknroll on Ubuntu.

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search