Home > Backend Development > PHP Problem > How to solve php mysql 500 error problem

How to solve php mysql 500 error problem

藏色散人
Release: 2023-03-03 16:36:01
Original
3347 people have browsed it

php mysql 500 error solution: first enter the "ext/mysql" directory of the php source code; then run phpize; then compile and install through the command "make && make install" to generate "mysql.so"; finally Just modify the "php.ini" file.

How to solve php mysql 500 error problem

Recommended: "PHP Video Tutorial"

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

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

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

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

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 to generate a configure file (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 the 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, 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. To test, add the php file in the web directory, such as /usr/local/nginx/html/mysql.php

<?php
$con = mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;);
if($con){
    die(&#39;ok&#39;);
}else{
    die(&#39;Could not connect: &#39; . mysql_error());
}
Copy after login

The above is the detailed content of How to solve php 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