Make PHP support MySql in Linux -- find the MySQL that disappears

Source: Internet
Author: User

Problem

Recently I have been busy with a Courseware recording system. During the past two days, I found that a PHP script for updating the database on the server had a problem, but some of them should have built-in functions but could not be run. So I started the investigation...

The server is a centos system, where PHP may be included during system installation. I tested the php Command and found a problem, so I re-installed php5. I downloaded the PhP5 installation package to compile and install it. -- With-mysql = MySQL installation directory should be added during configure; otherwise, an error will be reported during compilation.

Configure: Error: cannot find MySQL header files under/usr/local/src/mysql-5.1.14-beta-linux-i686-glibc23/include /.

Note that the mysql client library is not bundled anymore !", However, I cannot find the MySQL installation directory on the server.

 

Thoughts

Normally, the MySQL installation directory is under usr/local, but no. So I found the second possible location:/usr/share/MySQL. Then I checked the MySQL my. ini file and the/etc/init. d/My. CNF file.

Finally, I first rpm-Qa | grep-I MySQL, and found that there are mysql-server and MySQL-client, and used rpm-QL xxxxxxx to check the installation location of both, there is still no directory I need. In this case, I only reflected that MySQL had a plug-in not installed... (I didn't configure the server before, so I may not install the mysql-devel package to support common MySQL server functions. Some lib required for development)

Try

So hurry to Yum-search MySQL, find the mysql-devel package, and install it. An error is returned, indicating that it is in conflict with MySQL-server !!!??? Then I simply found an RPM package, and then rpm-IVH MySQL-devel-community-5.1.33-0.rhel5.i386.rpm, successfully installed this module. Re-compile PHP, and no error is reported. Make and make install.

In this case, an error is returned when the PHP filename command is available... I used PHP-m to view the information of the module installed in PHP. There was no MySQL module ...????????

Solution

Finally, I took out the killer: directly install the MySQL module to PHP:

1. Go to PHP/EXT/MySQL:
Cd php/EXT/MySQL
2. Run the phpize command. The command must be executed in the PHP Module Directory. If it is executed in another directory, an error is returned:
Phpize
After execution, this directory generates a configure script.
3. Collect the information and write down the result. You will get it later:
Which PHP-config
Write down result 1
Find/-name mysql. h
Write down result 2
4. If result 2 is not found, the MySQL development library is not installed. The installation will be performed in this step.
Under centos:
Yum install mysql-devel
Under Ubuntu:
Apt-Get install libmysqlclient-Dev
After installation, run
Find/-name mysql. h
Write down result 2
5. Start Configuration
./Configure -- With-PHP-Config = Result 1 -- With-mysql = Result 2 prefix
NOTE: With-mysql = is not followed by the MySQL directory, but its prefix. For example, if the result 2 is/usr/include/MySQL. H, you only need to write -- With-mysql =/usr.

6. Compile
Make & make install
If it succeeds, the following message is displayed:
Installing shared extensions:/usr/local/lib/PHP/extensions/no-debug-non-ZTS-xxxxxxx/
7. Modify PHP. ini
Found; Extension = php_mysql.dll changed
Extension = mysql. So
8. Restart PHP-FPM.
Or simply restart the server.
9 open phpinfo () and you can see that MySQL has been successfully installed.

Solution part reference: http://yubosun.akcms.com/tech/install-extension-php-mysql.htm

 

Finally, the PHP filename command was successfully run.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.