Installing Apache2 With PHP5 And MySQL Support On Ubuntu 10.04 (LAMP) - Page 2

5 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://192.168.0.100/info.php):

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.

 

6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

aptitude search php5

Pick the ones you need and install them like this:

aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:

 

7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:

aptitude install phpmyadmin

You will see the following questions:

Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- No

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:

 

8 Links

Share this page:

15 Comment(s)

Add comment

Comments

From: Maxime at: 2010-06-06 18:34:43

A simpler and quicker way to do all of this in one line  :

sudo tasksel install lamp-server

From: Thom Brown at: 2010-06-09 11:56:53

Or you could use a proper, reliable, consistent and more powerful RDBMS... PostgreSQL. ;)

From: Anonymous at: 2010-06-21 12:19:07

sudo apt-get install lamp-server^

Don't forget the ^ at the end, otherwise apt-get won't recognize the package.

From: Anonymous at: 2010-07-30 08:26:17

Do that, and you will have a system full of packets that you don't need, but they still use your CPU.

From: Anonymous at: 2010-07-30 08:25:04

Hi,

I found a mistake in your tutorial.

 When installing PHP5, to be able to use MySQL, you must also install "php5-mysql" packet: "aptitude install php5-mysql". After that - restart server with "/etc/init.d/apache2 restart". (all must be done with root access either using root console "sudo su" or adding prefix "sudo" to commands)

From: Anonymous at: 2010-10-11 20:53:08

okay just to inform everyone

you cant use aptitude on a standard fresh install as it is not installed.

just use apt-get instead or install aptitude

 

Just so you know

From: ashique zakariyya at: 2012-04-12 06:14:25

I can give you better solution for installation.

i found great article about this
some fixes also there, auto configuration:

http://www.discusswire.com/mysql-installation-ubuntu-10-04/

From: Anonymous at: 2010-06-07 15:21:07

Simpler does not always entail safer.

From: Anonymous at: 2010-06-06 18:27:38

Funny! I installed LAMP on my Ubunut netbook using the following command:

$ sudo apt-get install lamp-server^

NOTE: the carat (^) at the end of the lamp-server name is NECESSARY.

LAMP Server installation prompted me to assign a passwd for mysql root account.

I installed phpmyadmin using the following command:

$ sudo apt-get install phpmyadmin

PHPMyAdmin installation prompted me to give it mysql root passwd and then create a phpmyadmin account.

I feel the steps in my note/comment are simpler than the steps outlined in the article. Why would you recommend the steps outlined in your article? Am I missing something?

 

From: Abe at: 2010-06-09 13:14:42

It is a lot simpler when you use XAMPP

 http://www.apachefriends.org/en/xampp.html

 http://www.apachefriends.org/en/xampp-linux.html#377

 You get all the following installed in couple easy steps.

 Apache 2.2.14, MySQL 5.1.41, PHP 5.3.1 & PEAR + SQLite 2.8.17/3.6.16 + multibyte (mbstring) support, Perl 5.10.1, ProFTPD 1.3.2c, phpMyAdmin 3.2.4, OpenSSL 0.9.8l, GD 2.0.1, Freetype2 2.1.7, libjpeg 6b, libpng 1.2.12, gdbm 1.8.0, zlib 1.2.3, expat 1.2, Sablotron 1.0, libxml 2.7.6, Ming 0.4.2, Webalizer 2.21-02, pdf class 009e, ncurses 5.3, mod_perl 2.0.4, FreeTDS 0.63, gettext 0.17, IMAP C-Client 2007e, OpenLDAP (client) 2.3.11, mcrypt 2.5.7, mhash 0.8.18, eAccelerator 0.9.5.3, cURL 7.19.6, libxslt 1.1.26, libapreq 2.12, FPDF 1.6, XAMPP Control Panel 0.8, bzip 1.0.5, PBXT 1.0.09-rc, PBMS 0.5.08-alpha, ICU4C Library 4.2.1 

From: Anonymous at: 2010-06-09 11:17:51

Funny! to the 1st poster why not just type tasksel and select LAMP

From: Anonymous at: 2010-06-30 14:35:53

hun ? and get hacked :|

From: Anonymous at: 2010-08-14 07:39:44

i've followed the steps and it works perfectly when i am connected to the internet, but when i am offline it doesn't work. could anyone help me solve this problem.

From: Marcio Mariano at: 2010-09-08 03:07:11

Great job man !!!

A long time i search a good information and now i founddddddddd !!!

sorry for my bad english


 

From: Daniel Malaquias at: 2012-03-22 00:53:38

Great Job from Brazil man