Installing Apache2 With PHP5 And MySQL Support On CentOS 5.6 (LAMP) - Page 2

5 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www/html. 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/html/info.php


Now we call that file in a browser (e.g.

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 php-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:

yum search php

Pick the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Now restart Apache2:

/etc/init.d/httpd restart

Now reload 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.

First we enable the RPMforge repository on our CentOS system as phpMyAdmin is not available in the official CentOS 5.6 repositories:

On x86_64 systems:

rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

On i386 systems:

rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.i386.rpm

phpMyAdmin can now be installed as follows:

yum install phpmyadmin

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):

vi /etc/httpd/conf.d/phpmyadmin.conf

#  Web application to manage MySQL

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Next we change the authentication in phpMyAdmin from cookie to http:

vi /usr/share/phpmyadmin/

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';

Restart Apache:

/etc/init.d/httpd restart

Afterwards, you can access phpMyAdmin under


8 Links

Share this page:

6 Comment(s)

Add comment


From: slapper at: 2011-06-14 18:35:59

From Centos 5.6 you have the option to install php 5.3 (  specifically 5.3.3 ). You can install it by typing :

yum install php53

More packages are availabe

================= Matched: php53 ====================

php53.i386 : PHP scripting language for creating dynamic web sites

php53-bcmath.i386 : A module for PHP applications for using the bcmath library

php53-cli.i386 : Command-line interface for PHP

php53-common.i386 : Common files for PHP

php53-dba.i386 : A database abstraction layer module for PHP applications

php53-devel.i386 : Files needed for building PHP extensions

php53-gd.i386 : A module for PHP applications for using the gd graphics library

php53-imap.i386 : A module for PHP applications that use IMAP

php53-intl.i386 : Internationalization extension for PHP applications

php53-ldap.i386 : A module for PHP applications that use LDAP

php53-mbstring.i386 : A module for PHP applications which need multi-byte string handling

php53-mysql.i386 : A module for PHP applications that use MySQL databases

php53-odbc.i386 : A module for PHP applications that use ODBC databases

php53-pdo.i386 : A database access abstraction module for PHP applications

php53-pgsql.i386 : A PostgreSQL database module for PHP

php53-process.i386 : Modules for PHP script using system process interfaces

php53-pspell.i386 : A module for PHP applications for using pspell interfaces

php53-snmp.i386 : A module for PHP applications that query SNMP-managed devices

php53-soap.i386 : A module for PHP applications that use the SOAP protocol

php53-xml.i386 : A module for PHP applications which use XML

php53-xmlrpc.i386 : A module for PHP applications which use the XML-RPC protocol

From: robocatsrule at: 2011-07-25 18:28:08

The "mysql_secure_installation" step failed with the error:


Remove anonymous users? [Y/n] Y

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

... Failed!


To solve this problem change line (~50) in the script: /usr/bin/mysql_secure_installation


echo "password=$rootpass"


echo "password='$rootpass'"

After this change, no problems!

The original reference for this bug fix is at:

I hope this saves others some time.

From: robocatsrule at: 2011-07-25 19:02:56

After the apache2 steps, open the "www" ports in the firewall using:


From: Anonymous at: 2011-06-17 16:47:48

Why stick to PHP 5.1.6 ??

Perhaps time for SL 6? It has PHP 5.3 

From: Anonymous at: 2011-09-23 08:23:59

i did the installation but im not getting the post image in the browser i get other once - mySQL image

see >>

From: Anonymous at: 2011-09-24 06:25:42

i did the installation but im not getting the mySQL post image in the browser