How to compile and install mysql in php under linux

藏色散人
Release: 2023-03-11 15:04:01
Original
2231 people have browsed it

How to compile and install mysql with php under Linux: 1. Enter the pdo_mysql directory of the php source code package installation path; 2. Run phpize; 3. Run config; 4. Compile and install to generate mysql.so; 5. Add mysql.so extension configuration; 6. Restart php-fpm.

How to compile and install mysql in php under linux

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

How to compile and install php under linux mysql?

PHP compile and install the extension of mysql.so

1. Enter the pdo_mysql directory of the php source code package installation path

/usr/local/src/php/package/php-5.6.29/ext/pdo_mysql
Copy after login

2. Run phpize, in the Generate a configure file in the directory

/usr/local/php/bin/phpize
Copy after login

3. Run config, specify the mysql and php directory locations

./configure --prefix=/data/php --with-pdo-mysql=/data/mysql/bin/mysql_config --with-php-config=/data/php/bin/php-config --with-zlib-dir=/root/php-5.6.25/ext/zlib
Copy after login

4. Compile and install, generate mysql.so

make && make install
Copy after login

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

vim /data/php/etc/php.ini
extension=pdo_mysql.so
Copy after login

6. Restart php-fpm

service php-fpm restart
Copy after login

test, add php files in the web directory, such as /data/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

Access the URL, such as: http://ip/mysql.php

If ok is displayed, the configuration is successful

Recommended learning: "PHP video tutorial

The above is the detailed content of How to compile and install mysql in php under linux. 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