当前位置:Gxlcms > PHP教程 > PHPMySQLonCentos5.x

PHPMySQLonCentos5.x

时间:2021-07-01 10:21:17 帮助过:14人阅读

In this tutorial I will show you how to install MySQL support in PHP application.

PHP MySQL on Centos 5.x

This Tutorial show you how to install MySQL support into php. If you have downloaded and installed Centos 5.x then you won't get MySQL support into your php application.

In this tutorial I will show you how you can install MySQL support and install using MySQL database from your php program.

We will use the yum tool to install MySQL support. The yum tool is nice tool to update software on Linux machine.

Steps 1:

If PHP is not installed then follow the following steps. If PHP is already installed go to the Step 2.

Install php on Linux: If PHP is not install then you can issue the following command to install PHP:

[root@localhost ~]# yum install php

The above command will install PHP on Linux machine. Next step is to add MySQL support into PHP.

Step 2:

First find all the modules of the PHP that 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 that use IMAP.

php-ldap.i386 : A module for PHP applications that 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 that use MySQL databases.

php-ncurses.i386 : A module for PHP applications for using ncurses interfaces

php-odbc.i386 : A module for PHP applications that 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 way 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 that 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 to be updated

--> Processing Dependency: libc-client.so.1 for package: php-imap

---> Package php-mysql.i386 0:5.1.6-23.2.el5_3 set to be updated

--> Processing Dependency: php-pdo for package: php-mysql

---> Package php-xml.i386 0:5.1.6-23.2.el5_3 set to be updated

---> Package php-gd.i386 0:5.1.6-23.2.el5_3 set to be updated

---> Package php-xmlrpc.i386 0:5.1.6-23.2.el5_3 set to be updated

---> Package php-odbc.i386 0:5.1.6-23.2.el5_3 set to be updated

---> Package php-pear.noarch 1:1.4.9-4.el5.1 set to be updated

--> Running transaction check

---> Package libc-client.i386 0:2004g-2.2.1 set to be updated

---> Package php-pdo.i386 0:5.1.6-23.2.el5_3 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

Package Arch Version Repository Size

================================================================================

Installing:

php-gd i386 5.1.6-23.2.el5_3 updates 116 k

php-imap i386 5.1.6-23.2.el5_3 updates 53 k

php-mysql i386 5.1.6-23.2.el5_3 updates 85 k

php-odbc i386 5.1.6-23.2.el5_3 updates 52 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 95 k

php-xmlrpc i386 5.1.6-23.2.el5_3 updates 56 k

Installing for dependencies:

libc-client i386 2004g-2.2.1 base 516 k

php-pdo i386 5.1.6-23.2.el5_3 updates 64 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 | 52 kB 00:00

(2/9): php-imap-5.1.6-23.2.el5_3.i386.rpm | 53 kB 00:00

(3/9): php-xmlrpc-5.1.6-23.2.el5_3.i386.rpm | 56 kB 00:00

(4/9): php-pdo-5.1.6-23.2.el5_3.i386.rpm | 64 kB 00:00

(5/9): php-mysql-5.1.6-23.2.el5_3.i386.rpm | 85 kB 00:01

(6/9): php-xml-5.1.6-23.2.el5_3.i386.rpm | 95 kB 00:01

(7/9): php-gd-5.1.6-23.2.el5_3.i386.rpm | 116 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 59 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 you are all 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 be able to access MySQL from PHP application. Hope this tutorial will help you in installing MySQL support in PHP.

Quote: http://www.roseindia.net/linux/tutorial/linuxtips/php-mysql-centos.shtml

人气教程排行