PHP Installation mysql.so Extensions

Source: Internet
Author: User
Tags php and mysql mysql index

In PHP, the Mysql_connect module has been gradually deprecated, I did not install the MySQL extension when setting up the environment, but today in the maintenance of an old project, an error occurred

Fatal error:uncaught error:call to undefined function mysql_connect ()

So Google, found that if both PHP and MySQL have been installed, you can use the Phpize tool to manually compile the build mysql.so extension to solve

Here are the steps to proceed:
1. Enter the PHP source Ext/mysql directory

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

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

/usr/local/php/bin/phpize

3. Run configure, indicating the Php-config file location (/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, generate mysql.so

Make && make install

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

Extension=mysql.so

6. Restart PHP-FPM

Service PHP-FPM Restart

7. Test, add php files to 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 URLs, such as: http://192.168.8.9/mysql.php
Show OK, the configuration is successful

See MORE:
MySQL optimization
MySQL each storage engine
MySQL Lock explanation
MySQL Transaction
MySQL index type

PHP Installation mysql.so Extensions

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.