One, prepare1. Environment
System platform: Red Hat Enterprise Linux Server release 7.3 (MAIPO)
Kernel version: 3.10.0-514.el7.x86_64
2. Download the installation package
http://php.net/downloads.php
3. Installation related dependencies
# yum-y Install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel OpenSSL openssl-devel LIBCU Rl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 Recode recode-devel Libtidy Libtidy-devel
Three, installation 1, decompression
# tar ZXVF php-7.1.0.tar.gz
2. Compiling
# CD php-7.1.0
#./configure--prefix=/usr/local/php7--with-curl--with-freetype-dir--with-gd--with-gettext--with-iconv-dir-- With-kerberos--with-libdir=lib64--with-libxml-dir--with-mysqli--with-openssl--with-pcre-regex--with-pdo-mysql- -with-pdo-sqlite--with-pear--with-png-dir--with-xmlrpc--with-xsl--with-zlib--with-zlib-dir--with-mhash-- With-mcrypt--with-openssl-dir--with-jpeg-dir \
--with-apxs2=/usr/local/apache/bin/apxs--enable-gd-jis-conv--enable-fpm--enable-bcmath--enable-libxml-- Enable-inline-optimization--enable-gd-native-ttf--enable-mbregex--enable-mbstring--enable-opcache-- Enable-pcntl--enable-shmop--enable-soap--enable-sockets--enable-sysvsem--enable-xml--enable-zip
Errors that may occur:
Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
Workaround: Install libmcrypt
Address: Https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
The following error occurred after compiling:
Configure:error:Don ' t know how to define struct flock on the This system, set--enable-opcache=no
# VI Local.conf
Add the following statement
/usr/local/lib
# Ldconfig
Then execute configure, compile through
4. Installation
# make
# make Install
5. Test whether the installation is successful
View PHP Version
#/usr/local/php7/bin/php-v
Display version information to prove that the installation was successful
IV. configuration 1, configure PHP
1) configuration php.ini
Php.ini-development is suitable for development testing, such as the local test environment, Php.ini-production has a high security settings, suitable for server on-line operation when the product. The general modification php.ini-production is php.ini, which is more secure and ensures that the test environment (local) is consistent with the formal environment (online).
# CD php-7.1.0
# CP Php.ini-production/usr/local/php/etc/php.ini
2) Configuring fpm
# cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
# cp/usr/local/php7/etc/php-fpm.d/www.conf.default/usr/local/php7/etc/php-fpm.d/www.conf
Note: PHP7 www.conf This configuration file configuration phpfpm port number and other information, if you modify the default 9000 port number should be changed here, and then change the Nginx configuration
# CP PHP-7.1.0/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
# chmod +X/ETC/INIT.D/PHP-FPM
# chkconfig--add php-fpm
3) Start command
Start
#/ETC/INIT.D/PHP-FPM Start
Restart
# Killall PHP-FPM
#/ETC/INIT.D/PHP-FPM
2. Configure Apache to support PHP
Apache is invoking PHP as its own module.
1) Configuration httpd.conf
# vi/usr/local/apache/conf/httpd.conf Find AddType application/x-gzip. gz. tgz Add the following below
AddType application/x-httpd-php. PHP (with spaces in front)
AddType Application/x-httpd-php-source. PHPS (front with spaces)
At the end, add the following configuration
<filesmatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
2) Write
Write a PHP test page info.php, put it in the/usr/local/apache/htdocs directory
1 <? PHP 2 Phpinfo (); 3 ?>
3) Restart Apache
#/usr/local/apache/bin/apachectl-k Restart
4) Testing
3.
Configure Nginx so that it supports PHP
Nginx is a fastcgi way to combine nginx, can be understood as Nginx proxy php fastcgi
1) configuration
Location ~ \.php$ { root html; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename /$document _root$fastcgi_script_name; Include Fastcgi_params;}
2) Write PHP code
Write a PHP test page info.php, put it in the Apache/htdocs directory
1 <? php2 phpinfo(); 3?>
3) Reload Nginx configuration
#/usr/local/nginx/sbin/nginx-s Reload
4) Testing
PHP "First installment"