Table of Contents
PHP-FPM
MySQL support
A few questions
Compilation problem: cc: Internal error: Killed (program cc1)
PHP reported that the mysql service cannot be found
Home php教程 php手册 Compilation and installation of PHP7 under CentOS, MySQL support and solutions to some problems

Compilation and installation of PHP7 under CentOS, MySQL support and solutions to some problems

Jul 06, 2016 pm 01:30 PM
centos mysql php7 Install support compile

I recently tried php7 and encountered some problems in compiling and supporting MySQL. I believe many students have encountered the same problem, so I will talk about the process here. To put it simply, there are only 3 steps to compile PHP7: 1. ./buildconf --force 2. ./configure 3. make make install Steps 1 and 3 are nothing to worry about. Configure is the key to compilation and involves

I recently tried php7 and encountered some problems in compiling and supporting MySQL. I believe many students have encountered the same problem, so I will talk about the process here. Simply speaking, compiling PHP7 only requires 3 steps:

1. ./buildconf --force

2. ./configure

3. make && make install

There is nothing to worry about in steps 1 and 3. Configure is the key to compilation and involves PHP’s support for some libraries. Here we use the minimum support, including MySQL:

curl

gd

fpm

mysqlnd

The reason why we use curl and gd as examples is to make it clear that these third-party libraries must be installed before compiling PHP. You can directly use yum to install them in the default location, or you can compile and install them to a specified location. After yum is installed, , there is no need to specify the installation location of the library when compiling. You can search for a lot about installing these libraries. Let’s take a look at the basic configure

./configure --PRefix=/apps/php/php7.<span style="color: #800080;">0</span> --enable-mbstring --with-curl --with-gd --with-config-<span style="color: #0000ff;">file</span>-path=/apps/php/php7.<span style="color: #800080;">0</span>/etc/ --enable-fpm --enable-mysqlnd --with-pdo-mysql=mysqlnd
Copy after login

PHP-FPM

Regarding fpm, I believe it goes without saying that using it to support PHP is a better choice. PHP5.3.3 has built-in php-fpm, so of course it is also available in PHP7. You only need to --enable-fpm. That’s it

php-fpm parameters:

--start Start

--stop force termination

--quit smooth termination

--restart Restart

--reload smoothly reloads php’s php.ini

--logrotate Re-enable log file

MySQL support

I’ll focus on this, because I spent a little time on it, and I don’t know which version it started from. PHP no longer wants to use the mysql library to support mysql connections. It has enabled mysqlnd to support it. I heard it is faster than libmysql. Many, PHP5.x can also use libmysql. PHP7 seems to have canceled the support. The --with-mysql parameter is not available in compilation. Only --with-mysqli and --with-pdo-mysql are supported. You can check the configure parameters. Come and find out:

./configure -help | <span style="color: #0000ff;">grep</span> mysql
Copy after login

As you can see, PHP hopes to use mysqlnd to support MySQL, so the parameters can be written like this:

--enable-mysqlnd

--with-mysqli=mysqlnd

--with-pdo-mysql=mysqlnd

mysqlnd does not require mysql support, so it can be compiled and passed without installing mysql first. Start php-fpm and check phpinfo. You can see that mysqlnd and pdo_mysql indicate that php can already support mysql (pdo is used here) , mysqli is the same)

A few questions

Compilation problem: cc: Internal error: Killed (program cc1)

This is the first time I encountered this problem. It turned out that my Alibaba Cloud server turned off swap and there was not enough memory, so I reported this error. The solution is very simple, just add the --disable-fileinfo parameter when configure.

PHP reported that the mysql service cannot be found

As it said, it was indeed not found. Take a look at the pdo_mysql.default_socket item in phpinfo

Where is mysql.sock? Let’s take a look at the real location of mysql.sock. Use the command: ps -ef|grep mysql to view:

Obviously not in the same location, my correct location is: /var/lib/mysql/mysql.sock

So, modify php.ini, find pdo_mysql.default_socket, change it to your actual location, and restart php-fpm. Unfortunately, although php.ini has this configuration, after modification, it does not work. It is best to compile When , specify the location of mysql.socket:

--with-mysql-sock=/var/lib/mysql/mysql.sock

If that still doesn’t work, you can create a soft link to mysql.sock in the /tmp directory:

<span style="color: #0000ff;">ln</span> -s /var/lib/mysql/mysql.sock mysql.sock
Copy after login

Restart php-fpm again, I believe it is running normally. If you need more libraries supported by PHP, you can compile again and add the required support when configure, which is --with-xxx. Remember that if it is a third-party library, you must install these libraries first.


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the &quot;MySQL Native Password&quot; plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

How to delete data from MySQL table using PHP? How to delete data from MySQL table using PHP? Jun 05, 2024 pm 12:40 PM

PHP provides the following methods to delete data in MySQL tables: DELETE statement: used to delete rows matching conditions from the table. TRUNCATETABLE statement: used to clear all data in the table, including auto-incremented IDs. Practical case: You can delete users from the database using HTML forms and PHP code. The form submits the user ID, and the PHP code uses the DELETE statement to delete the record matching the ID from the users table.

See all articles