Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Compilation and installation of PHP7 under CentOS, support of MySQL and how to solve some common problems

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the compilation and installation of PHP7 under CentOS and the support of MySQL and how to solve some common problems. The article is very detailed and has a certain reference value. Interested friends must read it!

Recently, I tried PHP7 and encountered some problems in compiling and supporting MySQL. I believe many students also encountered it, so I'll talk about this process here. In a nutshell, compiling PHP7 takes only three steps:

1. / buildconf-- force

2 、. / configure

3. Make & & make install

Step 1 or 3, there is nothing to control. Configure is the key to compilation, which involves PHP's support for some libraries. Here we use the minimum support, including MySQL:

Curl

Gd

Fpm

Mysqlnd

The reason to take curl and gd, for example, is to make it clear that these three-party libraries have to be installed before compiling PHP, you can directly use yum to install in the default location, or you can compile and install to a specified location. After yum installation, you do not need to specify the installation location of the library. About installing these libraries, you can search for many. Let's take a look at the basic configure

. / configure-prefix=/apps/php/php7.0-enable-mbstring-with-curl-with-gd-with-config-file-path=/apps/php/php7.0/etc/--

Enable-fpm-enable-mysqlnd-with-pdo-mysql=mysqlnd

PHP-FPM

With regard to fpm, I believe it is needless to say that using it to support PHP is a better choice. PHP5.3.3 has built-in php-fpm from the beginning, so of course it is also available in PHP7. You just need to-- enable-fpm.

Php-fpm parameters:

-- start startup

-- stop forced termination

-- smooth termination of quit

-- restart restart

-- reload reloads php's php.ini smoothly

-- logrotate re-enables log files

MySQL support

Focus on this, because I spent some time on it, I don't know from which version, PHP no longer wants to use mysql's library to support mysql connections, enabled mysqlnd to support it, I heard that it is much faster than libmysql, PHP5.x can also use libmysql,PHP7 seems to have cancelled the support, compilation does not have-- with-mysql parameter, only supports-- with-mysqli and-- with-pdo-mysql You can know by looking at the parameters of configure:

. / configure-help | grep mysql

As you can see, PHP wants to use mysqlnd to support MySQL, so the parameters can be written as follows:

-- enable-mysqlnd

-- with-mysqli=mysqlnd

-- with-pdo-mysql=mysqlnd

Mysqlnd does not need mysql support, so it can be compiled 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 (the same is used here as pdo,mysqli)

A few questions

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

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

Mysql service could not be found in PHP

As it said, I didn't find it. Look at the pdo_mysql.default_socket item in phpinfo.

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

Obviously not in one position, my correct position is: / var/lib/mysql/mysql.sock

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

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

If not, you can set up a soft link to mysql.sock under the / tmp directory:

Ln-s / var/lib/mysql/mysql.sock mysql.sock

Restart php-fpm again. I believe it is working properly. If you need more libraries supported by PHP, you can compile again and add the required support in configure, that is, with-xxx. Remember that if it is tripartite, you have to install these libraries first.

The above is all the contents of this article entitled "compilation and installation of PHP7 under CentOS, support of MySQL and how to solve some common problems". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report