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

Want to support HowtoForge? Become a subscriber!
 
Submitted by CSch (Contact Author) (Forums) on Mon, 2011-10-17 18:19. ::

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by discount six fl... (not registered) on Wed, 2012-06-13 10:04.
"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.
Submitted by Dmitry (not registered) on Thu, 2012-03-22 03:41.
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)

Submitted by Anonymous (not registered) on Sat, 2012-02-04 05:51.

I had to add:

 ln -s /usr/share/phpmyadmin phpmyadmin

to get it working

Submitted by Anonymous (not registered) on Sun, 2012-02-05 03:01.

Sorry, posted too quickly; it should read:

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

Submitted by Chris (not registered) on Wed, 2012-01-25 07:07.

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??

Submitted by Anonymous (not registered) on Thu, 2012-01-26 19:35.

sudo gedit /var/www/infp.php

Submitted by Anonymous (not registered) on Wed, 2012-03-14 01:37.
its better to use "gksu gedit" instead of "sudo gedit"
Submitted by Anonymous (not registered) on Tue, 2011-10-25 04:59.
Excellent guide thank you very much. It helped me a lot, everything worked perfectly.
Submitted by Anonymous (not registered) on Thu, 2011-10-20 23:59.
Why not just run "sudo apt-get install lamp-server^ phpmyadmin"?
Submitted by Rob (not registered) on Mon, 2011-10-31 11:36.

This worked for me:

sudo apt-get install lamp-server^ phpmyadmin

Submitted by Anonymous (not registered) on Wed, 2012-02-15 12:11.

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

 THX!

Submitted by Anonymous (not registered) on Wed, 2012-03-14 01:51.
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)