PHP connection MySQL mysql_connect () function is not available, reported 500 error

Source: Internet
Author: User
Tags fpm

I did not install the MySQL extension when I was setting up the environment, but I got an error while maintaining a project today.


Fatal error:uncaught error:call to undefined function mysql_connect ()

You can use the Phpize tool to manually compile the build mysql.so extension to resolve


Here are the steps to proceed:

1. Enter the PHP source Ext/mysql directory

cd/home/oldboy/tools/php-5.5.32/ext/mysql/

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

/application/php/bin/phpize

3. Run configure to indicate the Php-config file location (/application/php/bin/php-config) and MySQL installation directory

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

4. Compile and install, generate mysql.so

Make && make install

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

Extension=mysql.so

6. Restart PHP-FPM

Service PHP-FPM Restart

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

Copy Code

<?php

$con = mysql_connect (' localhost ', ' root ', ');

if ($con) {

Die (' OK ');

}else{

Die (' Could not connect: '. Mysql_error ());

}


This article is from "Poetry and Distance" blog, please be sure to keep this source http://dreammoon.blog.51cto.com/12317841/1919907

PHP connection MySQL mysql_connect () function is not available, reported 500 error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.