Get the App
SLTechnology News&Howtos  ›  Development  › 

How php5.6 installs mysql extensions

Shulou Source: shulou.com Published: 2022-06-03 10:52:02 11月15日 Update

This article mainly introduces php5.6 how to install mysql extension, the article is very detailed, has a certain reference value, interested friends must read it!

Php5.6 installs the mysql extension: 1, download the source package of the extension and decompress it; 2, execute phpize;3, generate makefile, execute make and make install commands; 4, modify php.ini configuration file; 5, restart httpd service.

The operating environment of this paper: centos 7 system, php 5.6, thinkpad T480 computer.

Recently, I accidentally found an error while maintaining an old project, the error message: "Fatal error: Uncaught Error: Call to undefined function mysql_connect ()". After finding out the reason, I found that the mysql_connect module in php had been deprecated, and I didn't install the mysql extension when I was building the environment, so I made this error.

Now that we have found out the cause, it will be much more convenient to solve it. We can solve this problem by manually compiling and generating mysql.so extensions using the phpize tool.

The specific steps are as follows:

The first step is to download the source package for the pdo_mysql extension.

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

And then decompress.

# tar-zxvf PDO_MYSQL-1.0.2.tgz

Enter the unzipped directory and execute phpize.

# / usr/local/php/bin/phpizeConfiguring for:PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525

Next, generate the makefile. The next two parameters must be added, but I didn't add them at first, but both of them indicated that the header files for php-config and mysql could not be found.

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

Before make, we should also make a soft link to the header file of mysql. Because the directory was specified when mysql was installed, if you don't make a soft connection, you still can't find the header file.

# ln-s / usr/local/mysql/include/* / usr/local/include/

And then make and make install.

# make# make install

It will then be prompted as follows, meaning that the extension is installed in the following directory.

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

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

These are all the contents of the article "how to install mysql extensions in php5.6". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: File time directory error generation content reason source code environment article hint configuration accident two value information interest parameters can be passed through the command Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker MariaDB vpn MySQL