Recently tried PHP7, in compiling and supporting MySQL have encountered some problems, I believe many students also encountered, so here to chat about this process. In simple terms, compiling PHP7 takes only 3 steps:
1./buildconf--force
2./configure
3, make && make install
1, 3 steps, there is no good tube, configure is the key to compiling, involving PHP for some library support, here we use the smallest support, including MySQL:
Curl
Gd
Fpm
Mysqlnd
The reason for the curl and GD take, the purpose is to make it clear that these three-party library before compiling PHP, you can install the default location directly, or you can compile the installation to the specified location, yum installed, compile without specifying the location of the library installation, about the installation of these libraries, you can search for a lot of. Here's 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
About FPM, believe needless to say, use it to support PHP is a better choice, PHP5.3.3 began to have built the PHP-FPM, so PHP7 of course also have, only need to--enable-fpm to be able to
PHP-FPM Parameters:
--start start
--stop forced termination
--quit Smooth Termination
--restart reboot
--reload to reload PHP php.ini
--logrotate log file back on
MySQL Support
Focus on this, because it took a little time on it, do not know from which version, PHP is not in the hope of using MySQL library to support MySQL connection, enabled Mysqlnd to support, heard more than libmysql much faster, Php5.x can also use LIBMYSQL,PHP7 seemingly canceled support, the compilation has no--with-mysql parameters, only support--with-mysqli and--with-pdo-mysql, you can see the Configure parameters to know:
As you can see, PHP wants to use MYSQLND to support MySQL, so parameters can be written like this:
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
MYSQLND is not required MySQL support, so do not have to install MySQL as can be compiled through, start PHP-FPM, look at the phpinfo, can see MYSQLND and pdo_mysql that PHP has been able to support the MySQL (here with the PDO , mysqli empathy)
A few questions
Compile problem: cc:internal error:killed (program CC1)
This problem is the first encounter, it is my Aliyun server turned off swap, memory is not enough to report this error. The solution is very simple, configure with the--disable-fileinfo parameters can be.
The PHP report could not find the MySQL service
As it says, it's really not found, look at the Pdo_mysql.default_socket item in Phpinfo
Mysql.sock where, and then look at the real location of Mysql.sock, use the command: ps-ef|grep MySQL view:
Obviously not in a position, my correct position is:/var/lib/mysql/mysql.sock
So, revise php.ini, find Pdo_mysql.default_socket, change to your actual position, restart PHP-FPM, unfortunately, Although PHP.ini has this configuration, after modification, unexpectedly not, it is best to compile the time, specify the location of the Mysql.socket:
--with-mysql-sock=/var/lib/mysql/mysql.sock
If not, you can create a mysql.sock soft link to the/tmp directory:
Reboot once again php-fpm, believe already normal operation. If you need PHP to support more libraries, you can compile again, in the Configure when the need to add, that is,--with-xxx this, remember if the three-party, to install these libraries to just do oh.