First, download the PHP source code
Download Address: http://cn.php.net/downloads.php II, installation
1. Move the downloaded binary package to the/usr/local directory and unzip the package
Tar zxvf php-7.1.4.tar.gz
2, into the decompression of the PHP folder under/usr/local/php-7.1.4, installation dependencies, compile installation
Yum Install LIBXML2 Libxml2-devel
./configure--prefix=/usr/local/php--with-zlib--enable-zip--with-openssl--enable-fpm- With-libdir=lib64--without-pear--disable-phar
Make
Make test (you can allow the makes test command to detect compilation problems after compilation)
Make install
Summary information After the installation is complete:
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
Installing PHP CLI binary:/usr/local/php/bin/
Installing PHP CLI man page:/usr/local/php/php/man/man1/
Installing PHP FPM binary:/usr/local/php/sbin/
Installing PHP FPM defconfig:/usr/local/php/etc/
Installing PHP FPM man page:/usr/local/php/php/man/man8/
Installing PHP FPM Status page:/usr/local/php/php/php/fpm/
Installing phpdbg binary:/usr/local/php/bin/
Installing phpdbg man page:/usr/local/php/php/man/man1/
Installing PHP CGI binary:/usr/local/php/bin/
Installing PHP CGI man page:/usr/local/php/php/man/man1/
Installing Build Environment:/usr/local/php/lib/php/build/
Installing header files:/usr/local/php/include/php/
Installing helper Programs:/usr/local/php/bin/
Program:phpize
Program:php-config
Installing man pages:/usr/local/php/php/man/man1/
Page:phpize.1
Page:php-config.1
Installing PDO headers:/usr/local/php/include/php/ext/pdo/
3, PHP configuration
#php的配置文件为 php.ini
Cp/usr/local/php-7.1.4/php.ini-production/usr/local/php/lib/php.ini
#使得另一种方法来管理服务:
cp/usr/local/php-7.1.4/sapi/fpm/php-fpm/etc/init.d/php-fpm
#添加执行权限
chmod +x/etc/init.d/php-fpm
#php-FPM configuration file
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf
Modify the maximum number of PHP-FPM processes according to machine configuration, which is limited to/usr/local/php/etc/php-fpm.d/www.conf
Use Netstat-napo |grep "PHP-FPM" | Wc-l look at the current number of fastcgi processes, if the number is close to the upper limit of the configuration in conf, you need to increase the number of processes.
But also can not endlessly increase, depending on the server memory, you can php-fpm the number of child processes to 100 or more, in 4G memory server 200 on it.
Pm.max_children = 200
Pm.start_servers = 10
Pm.min_spare_servers = 8
Pm.max_spare_servers = 12
4. Set environment variable
Vi/etc/profile
After opening, add the following configuration at the bottom of the document:
Export Path=/usr/local/php/bin: $PATH
: wq! save Exit, execute the following command to make the change take effect
Source/etc/profile
5, start the PHP test
#启动
/etc/init.d/php-fpm
#测试php
Cd/usr/local/nginx/html
VI test.php
Add the following:
<?php
Echo Phpinfo ();
?>
: wq! save exit.
Browser input: http://10.62.32.123/test.php
If it appears: PHP Version 7.1.4 interface, showing PHP detailed configuration of the interface, indicating that the installation is correct
6, PHP restart, stop
PHP 7.1.4 Source code has been embedded in the PHP-FPM, just to configure the time to add the compilation parameters.
The compilation parameters about PHP-FPM have a –enable-fpm–with-fpm-user=www–with-fpm-group=www–with-libevent-dir=libevent location.
However, the php-fpm in the PHP 7.1.4 no longer supports PHP-FPM previously available commands such as/USR/LOCAL/PHP/SBIN/PHP-FPM (Start|stop|reload), which require signal control:
The master process can understand the following signals:
SIGINT, Sigterm immediately terminated.
Sigquit Smooth Termination
SIGUSR1 Reopen the log file
SIGUSR2 smooth overload of all worker processes and reload configuration and binary modules
Example:
PHP-FPM off:
Kill-sigint ' Cat/usr/local/php/var/run/php-fpm.pid '
PHP-FPM reboot:
KILL-SIGUSR2 ' Cat/usr/local/php/var/run/php-fpm.pid '
To view the number of PHP-FPM processes:
PS aux | Grep-c PHP-FPM
Netstat-anpo | grep "php-cgi" | Wc-l
Netstat-anop | grep "PHP-FPM" | Wc-l
Third, appendix
PHP compilation options Related instructions:
./configure--prefix=/usr/local/php \ #指定安装目录
--with-config-file-path=/usr/local/php/etc \ #指定配置文件的目录, default in php/ Lib full \
--enable-fpm \ Enable PHP fpm
--enable-mbstring \ Enable multibyte string support
--with-libdir=lib64 \
-- Without-pear \ Disable pear extension
--disable-phar \ Disable the Phar Function library for pear extensions
--enable-mysqlnd \ php-enabled MySQL driver
-- WITH-MYSQLI=MYSQLND \ Specify MySQL
--with-pdo-mysql=mysqlnd \ Specify MySQL