In this tutorial I'll show you the install MySQL support in PHP application.
PHP MySQL on Centos 5.x
This Tutorial show what to install MySQL support into PHP. If you had downloaded and installed Centos 5.x then you won ' t get MySQL support into your PHP application.
In this tutorial I'll show you how can install MySQL support and install the using MySQL database from your PHP program.
We'll use the Yum tool to install MySQL support. The Yum tool is a nice tool-to-update software on Linux machine.
Steps 1:
If PHP isn't installed then follow the following steps. If PHP is already installed go to the Step 2.
Install PHP on linux:if php isn't install then can issue the following command to install PHP:
[root@localhost ~]# Yum Install PHP
The above command would install PHP on Linux machine. Next step is to add MySQL support into PHP.
Step 2:
First find all the modules of the PHP so can be installed using following command:
[Root@localhost ~]# Yum Search php
Loaded Plugins:fastestmirror
Loading mirror speeds from cached hostfile
* base:virror.hanoilug.org
* updates:centosj.centos.org
* addons:virror.hanoilug.org
* extras:virror.hanoilug.org
================================= matched:php =================================
php-pear.noarch:php Extension and Application Repository framework
compat-readline43.i386:the readline 4.3 library for compatibility with older
: Software.
Fonts-arabic.noarch:fonts for Arabic
Gollem-h3.noarch:the Horde web-based File Manager.
Hddtemp.i386:Hard Disk Temperature Tool
Horde.noarch:The Common Horde Framework for all horde modules.
Imp-h3.noarch:the Internet Messaging program:webmail access to IMAP/POP3
: Accounts.
Ingo-h3.noarch:the Horde web-based Email Filter Rules Manager.
iproute.i386:Advanced IP Routing and network device configuration tools.
Kronolith-h3.noarch:the Horde Calendar application.
Libc-client.i386:c-client Mail access routines for IMAP and POP protocols
Mnemo-h3.noarch:the Horde Note Manager application.
Nag-h3.noarch:the Horde Task List Manager.
Php.i386:The PHP html-embedded scripting language. (Php:hypertext
: Preprocessor)
PHP-BCMATH.I386:A module for PHP applications for using the Bcmath library
Php-cli.i386:command-line Interface for PHP
Php-common.i386:common files for PHP
PHP-DBA.I386:A Database Abstraction Layer module for PHP applications
Php-dbase.i386:standard dbase module for PHP applications
Php-devel.i386:files needed for building PHP extensions.
PHP-GD.I386:A module for PHP applications for using the GD graphics library
PHP-IMAP.I386:A Module for PHP applications this use IMAP.
PHP-LDAP.I386:A Module for PHP applications this use LDAP.
PHP-MBSTRING.I386:A module for PHP applications which need multi-byte string
: Handling
Php-mcrypt.i386:standard PHP module provides mcrypt library support
Php-mhash.i386:standard PHP module provides mhash support
Php-mssql.i386:standard PHP module provides MSSQL support
PHP-MYSQL.I386:A Module for PHP applications this use MySQL databases.
PHP-NCURSES.I386:A module for PHP applications for using ncurses interfaces
PHP-ODBC.I386:A Module for PHP applications this use ODBC databases.
PHP-PDO.I386:A Database access Abstraction module for PHP applications
Php-pear-auth-sasl.noarch:pear:abstraction of various SASL mechanism
: Responses
Php-pear-db.noarch:pear:database Abstraction Layer
Php-pear-date.noarch:date and Time Zone Classes
Php-pear-file.noarch:common File and Directory routines
Php-pear-http-request.noarch:provides an easy-to-perform HTTP requests
php-pear-log.noarch:abstracted Logging Facility for PHP
Php-pear-mdb2.noarch:database Abstraction Layer
Php-pear-mdb2-driver-mysql.noarch:mysql MDB2 Driver
Php-pear-mail.noarch:class that provides multiple interfaces for sending
: Emails
Php-pear-mail-mime.noarch:classes to create and decode Mime messages
Php-pear-net-smtp.noarch:provides an implementation of the SMTP protocol
Php-pear-net-sieve.noarch:communication with timsieved
Php-pear-net-socket.noarch:network Socket Interface
Php-pear-net-url.noarch:easy parsing of URLs
Php-pecl-fileinfo.i386:fileinfo is a PHP extension that wraps the Libmagic
: library
Php-pecl-memcache.i386:extension to work with the Memcached caching daemon
PHP-PGSQL.I386:A PostgreSQL Database module for PHP.
Php-readline.i386:standard PHP module provides ReadLine library support
PHP-SNMP.I386:A module for PHP applications, that query snmp-managed devices.
PHP-SOAP.I386:A Module for PHP applications This use the SOAP protocol
Php-tidy.i386:standard PHP module provides tidy library support
PHP-XML.I386:A module for PHP applications which use XML
PHP-XMLRPC.I386:A module for PHP applications which use the XML-RPC protocol
READLINE.I386:A Library for editing typed command lines.
Readline-devel.i386:files needed to develop programs which use the ReadLine
: library.
Squirrelmail.noarch:SquirrelMail Webmail Client
Totem.i386:Movie Player for GNOME 2
Totem-devel.i386:libraries/include files for Totem
Totem-mozplugin.i386:mozilla Plugin for Totem
Turba-h3.noarch:the Horde Contact management application.
velocity.i386:java-based Template engine
[Root@localhost ~]#
Next Install the Php-mysql support using the following command:
[Root@localhost ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Loaded Plugins:fastestmirror
Loading mirror speeds from cached hostfile
* base:centos.aol.in
* updates:centos.aol.in
* addons:centos.aol.in
* extras:centos.aol.in
Setting up Install Process
Parsing Package Install arguments
Package php-ldap-5.1.6-23.2.el5_3.i386 already installed and latest version
Resolving Dependencies
--Running Transaction check
---> Package php-imap.i386 0:5.1.6-23.2.el5_3 Set updated
--processing dependency:libc-client.so.1 for Package:php-imap
---> Package php-mysql.i386 0:5.1.6-23.2.el5_3 Set updated
--processing dependency:php-pdo for Package:php-mysql
---> Package php-xml.i386 0:5.1.6-23.2.el5_3 Set updated
---> Package php-gd.i386 0:5.1.6-23.2.el5_3 Set updated
---> Package php-xmlrpc.i386 0:5.1.6-23.2.el5_3 Set updated
---> Package php-odbc.i386 0:5.1.6-23.2.el5_3 Set updated
---> Package php-pear.noarch 1:1.4.9-4.el5.1 Set updated
--Running Transaction check
---> Package libc-client.i386 0:2004g-2.2.1 Set updated
---> Package php-pdo.i386 0:5.1.6-23.2.el5_3 Set updated
--Finished Dependency Resolution
Dependencies resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
PHP-GD i386 5.1.6-23.2.el5_3 Updates K
Php-imap i386 5.1.6-23.2.el5_3 Updates
Php-mysql i386 5.1.6-23.2.el5_3 Updates K
Php-odbc i386 5.1.6-23.2.el5_3 Updates K
Php-pear Noarch 1:1.4.9-4.el5.1 Base 356 k
Php-xml i386 5.1.6-23.2.el5_3 Updates K
Php-xmlrpc i386 5.1.6-23.2.el5_3 Updates
Installing for dependencies:
Libc-client i386 2004g-2.2.1 base 516 K
Php-pdo i386 5.1.6-23.2.el5_3 Updates K
Transaction Summary
================================================================================
Install 9 Package (s)
Update 0 Package (s)
Remove 0 Package (s)
Total Download size:1.4 M
Is this OK [y/n]: Y
Downloading Packages:
(1/9): php-odbc-5.1.6-23.2.el5_3.i386.rpm | Kbytes 00:00
(2/9): php-imap-5.1.6-23.2.el5_3.i386.rpm | KB 00:00
(3/9): php-xmlrpc-5.1.6-23.2.el5_3.i386.rpm | KB 00:00
(4/9): php-pdo-5.1.6-23.2.el5_3.i386.rpm | KB 00:00
(5/9): php-mysql-5.1.6-23.2.el5_3.i386.rpm | KB 00:01
(6/9): php-xml-5.1.6-23.2.el5_3.i386.rpm | KB 00:01
(7/9): php-gd-5.1.6-23.2.el5_3.i386.rpm | KB 00:01
(8/9): php-pear-1.4.9-4.el5.1.noarch.rpm | 356 KB 00:05
(9/9): libc-client-2004g-2.2.1.i386.rpm | 516 KB 00:07
--------------------------------------------------------------------------------
Total KB/S | 1.4 MB 00:23
Running Rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing:php-pdo [1/9]
installing:libc-client [2/9]
Installing:php-imap [3/9]
INSTALLING:PHP-ODBC [4/9]
INSTALLING:PHP-XMLRPC [5/9]
INSTALLING:PHP-GD [6/9]
Installing:php-xml [7/9]
Installing:php-mysql [8/9]
Installing:php-pear [9/9]
installed:php-gd.i386 0:5.1.6-23.2.el5_3 php-imap.i386 0:5.1.6-23.2.el5_3 php-mysql.i386 0:5.1.6-23.2.el5_3 php-odbc.i386 0:5.1.6-23.2.el5_3 php-pear.noarch 1:1.4.9-4.el5.1 php-xml.i386 0:5.1.6-23.2.el5_3 php-xmlrpc.i386 0:5.1.6-23.2.el5_3
Dependency installed:libc-client.i386 0:2004g-2.2.1 php-pdo.i386 0:5.1.6-23.2.el5_3
complete!
Then restart the Apache. Now is all the set to go for your PHP development using MySQL database.
[root@localhost ~]# Service httpd restart
stopping httpd: [OK]
Starting httpd: [OK]
After restarting the Apache server, you should is able to access MySQL from PHP application. Hope This tutorial would help you on installing MySQL support in PHP.
Quote:http://www.roseindia.net/linux/tutorial/linuxtips/php-mysql-centos.shtml