Describes how to install mysql. so extension in PHP and mysql. so.
Preface
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 /)
/usr/local/php/bin/phpize
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.
extension=mysql.so
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: // 192.168.8.9/mysql. php
If OK is displayed, the configuration is successful.
Summary
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.