How to solve the php connection mysql 500 error problem

藏色散人
Release: 2023-03-12 12:46:02
Original
2627 people have browsed it

Solution to php connection mysql 500 error: 1. Enter the ext/mysql directory of the php source code; 2. Run phpize; 3. Run configure; 4. Compile and install to generate mysql.so; 5. Add mysql .so extension configuration; 6. Restart php-fpm.

How to solve the php connection mysql 500 error problem

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to solve the php connection mysql 500 error problem ?

The mysql_connect() function is not available when PHP connects to mysql, and a 500 error is reported

I did not install the mysql extension when setting up the environment, but today when maintaining a project, If an error occurs

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

You can use the phpize tool to manually compile and generate the mysql.so extension to solve the problem

The following are the steps:

1. Enter the ext/mysql directory of the PHP source code

cd /home/oldboy/tools/php-5.5.32/ext/mysql/
Copy after login

2. Run phpize and generate a configure file in this directory (php installation directory: /application/php/)

/application/php/bin/phpize
Copy after login

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

 ./configure --with-php-config=/application/php/bin/php-config --with-pdo-mysql=mysqlnd
Copy after login

4. Compile and install, generate mysql.so

make && make install
Copy after login

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

extension=mysql.so
Copy after login

6. Restart php-fpm

service php-fpm restart
Copy after login

7. Test, add php files in the web directory, such as /usr/local/nginx/html/mysql.php

Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve the php connection mysql 500 error problem. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!