Installing Apache2 With PHP5 And MySQL Support On Ubuntu 11.10 (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.23/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:

apt-cache search php5

Pick the ones you need and install them like this:

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

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload http://192.168.0.23/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:

apt-get 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.23/phpmyadmin/:

 

8 Links

Share this page:

20 Comment(s)

Add comment

Comments

From: deeplite at: 2011-10-22 02:13:42

sudo apt-get install aptitude

sudo aptitude install lamp-server

From: Rob at: 2011-10-31 10:19:43

The result of running the previously-mentioned commands:

$ sudo aptitude install lamp-server
Couldn't find any package whose name or description matched "lamp-server"
Couldn't find any package whose name or description matched "lamp-server"

Trying to install the same package using apt-get:

$ sudo apt-get install lamp-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package lamp-server

From: Anonymous at: 2011-11-08 20:40:54

sudo apt-gets install lamp-server^

 

he was missing the ^

From: samita at: 2012-03-13 16:23:39

thanks a lot for this article. It's amazing how a small character like ^ has kept me in the dark for weeks now

From: Ronald Matte at: 2011-11-23 23:46:13

I just installed LAMP on a Dell Opti-Plex I recently loaded with Ubuntu 11.10 according to the article.

Everything went so smooth I had to double check to make sure everything was  installed properly. Yes. apt-get is now my best friend, and this article and the tasks herein are on-point.

My first encounter with a non-MS OS was SCO Unix (way) back in 1992.

Thank you to all who contribute their long-labored hours and talent to developing and maintaining such a wonderful flavor of Linux.

 

Ronald Matte

nrmuscom@yahoo.com

From: Anonymous at: 2012-03-05 02:15:31

this couldnt of been any easier on ubuntu 11.10

From: Ovidiu at: 2012-04-18 14:55:05

thank you it it works great

From: Anonymous at: 2012-08-09 18:33:36

use the ip of your server or (your pc)

From: Anonymous at: 2011-10-20 22:59:49

Why not just run "sudo apt-get install lamp-server^ phpmyadmin"?

From: Rob at: 2011-10-31 10:36:26

This worked for me:

sudo apt-get install lamp-server^ phpmyadmin

From: Anonymous at: 2012-02-15 11:11:21

Hello. I am new. I made it. But how tu make it visible for the others in my network?:D

 THX!

From: Anonymous at: 2012-03-14 00:51:32

if you have a firewall installed, you will need to open a port, If not you just need to know the ipaddress of the computer to access it.

The apache server runs on port 80, you can verify this by doing something like this 

http://192.168.0.2:80 or http://192.168.0.2 from any other machine on your network. Change the ipaddress of the machine to match the server machine, you can find this out easily by typing "ifconfig" in your terminal without quotes. depending on whether its wired or wireless you will want either eth0 or wlan0 in most cases. the ip address will be listed as follows (in my case its this)

inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0

The first ipaddress is the ip that your router has assigned to your machine the rest you can ignore for these purposes. If you intend keeping the machine on for a length of time, you may want to consider setting up a dedicated ip in the router for the machine, the method for this is way beyond the scope of this page, but you will find plenty of advice on the net for your specific router.

If you want to access it locally on the machine itself, 127.0.1.1 (thats how it installed on mine) 

From: Anonymous at: 2011-10-25 03:59:43

Excellent guide thank you very much. It helped me a lot, everything worked perfectly.

From: Chris at: 2012-01-25 06:07:52

Maybe I am a noob but wtf ever.... when i try vi /var/www/info.php I can't figure out what to do. I have gotten every sort of pattern error. All i get is "swap" files. No info.php. Just info.php.swp

 

Any help??

From: Anonymous at: 2012-01-26 18:35:08

sudo gedit /var/www/infp.php

From: Anonymous at: 2012-03-14 00:37:54

its better to use "gksu gedit" instead of "sudo gedit"

From: Anonymous at: 2012-02-04 04:51:59

I had to add:

 ln -s /usr/share/phpmyadmin phpmyadmin

to get it working

From: Anonymous at: 2012-02-05 02:01:58

Sorry, posted too quickly; it should read:

 ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

From: Dmitry at: 2012-03-22 02:41:34

Very good tutorial, thanks. One comment: to make phpmyadmin to work needed to add a link as following: 

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

sudo /etc/init.d/apache2 reload

 (from: https://help.ubuntu.com/community/phpMyAdmin)

From: discount six flags tickets at: 2012-06-13 09:04:11

"http://192.168.0.2:80 or http://192.168.0.2 from any other machine on your network. Change the ipaddress of the machine to match the server machine, you can find this out easily by typing "ifconfig" in your terminal without quotes. depending on whether its wired or wireless you will want either eth0 or wlan0 in most cases. the ip address will be listed as follows (in my case its this)" - this worked for me.