How to install mysql extension in php5.6

王林
Release: 2023-03-12 21:06:02
Original
3857 people have browsed it

How to install mysql extension in php5.6: 1. Download the extended source code package and unzip it; 2. Execute phpize; 3. Generate makefile and execute make and make install commands; 4. Modify the php.ini configuration file ;5. Restart the httpd service.

How to install mysql extension in php5.6

The operating environment of this article: centos 7 system, php 5.6, thinkpad t480 computer.

Recently, I accidentally discovered an error while maintaining an old project. The error message: "Fatal error: Uncaught Error: Call to undefined function mysql_connect()". After finding out the cause, I found that the mysql_connect module in PHP has been deprecated, and I did not install the mysql extension when setting up the environment, so I got this error.

Now that we have identified the cause, it will be much easier to solve it. We can solve this problem by manually compiling and generating the mysql.so extension using the phpize tool.

The specific steps are as follows:

First, download the source code package of the pdo_mysql extension.

# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
Copy after login

Then decompression.

# tar -zxvf PDO_MYSQL-1.0.2.tgz
Copy after login

Enter the decompressed directory and execute phpize.

# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Copy after login

Generate the makefile below. The last two parameters must be added. I did not add them at first, but the result was that the header files of php-config and mysql could not be found.

# ./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
Copy after login

Before making, you need to make a soft connection to the mysql header file. Because the directory is specified when MySQL is installed, the header file will still not be found without making a soft connection.

# ln -s /usr/local/mysql/include/* /usr/local/include/
Copy after login

Then make and make install.

# make
# make install
Copy after login

The following prompt will appear, which means that the extension is installed in the following directory.

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
Copy after login

Modify the php.ini file

Modify: extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20100525/"

Add: extension=pdo_mysql.so

Restart httpd to reload the php configuration file

Recommended learning: php training

The above is the detailed content of How to install mysql extension in php5.6. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template