Describes how to install mysql. so extension in PHP and mysql. so.

Source: Internet
Author: User

Describes how to install mysql. so extension in PHP and mysql. so.


Because the mysql_connect module in PHP has been gradually deprecated, and I have not installed mysql extensions when setting up the environment, but an error is reported when I maintain an old project today.

Fatal error: Uncaught Error: Call to undefined function mysql_connect()

If php and mysql have been installed, you can use the phpize tool to manually compile and generate mysql. so extension.

The procedure is as follows:

1. Go to the ext/mysql directory of the php source code.

cd /usr/local/src/php-5.6.29/ext/mysql/

2. Run phpize to generate a configure file under this directory (php installation directory:/usr/local/php /)


3. Run configure to specify the location of the php-config file (/usr/local/php/bin/php-config) and the mysql installation directory (/usr/local/mysql /)

 ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr/local/mysql/

4. Compile and install and generate mysql. so

make && make install

5. Modify the php. ini file, add the mysql. so extension configuration, save and exit.

6. Restart php-fpm.

service php-fpm restart

7. Test the function of adding a php file in the web directory, such as/usr/local/nginx/html/mysql. php.

<?php$con = mysql_connect('localhost','root','');if($con){ die('ok');}else{ die('Could not connect: ' . mysql_error());}

Access URL, such as http: // php

If OK is displayed, the configuration is successful.


The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

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