CentOS 7 Compile and install php-7.1.6

Source: Internet
Author: User
Tags chmod fpm gmp install php

1, install the following package for the upcoming PHP installation configuration system environment

[root@localhost~] #yum install libxml2 libxml2-developenssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel Libjpeglibjpeg-devel libpng libpng-devel freetype freetype-devel GMP Gmp-devellibmcrypt libmcrypt-devel Readline-devel libxslt Libxslt-devel

2, download the PHP installation package from the Internet, as of 2017.7.4, the latest stable version of PHP can be found from the official Internet is php-7.1.6.tar.gz use the following instructions to download:

[root@localhost~] #wget http://cn2.php.net/distributions/php-7.1.6.tar.gz

3, Decompression PHP installation package, and into the installation file path

[root@localhost~]# TAR-ZXVF php-7.1.6.tar.gz

[root@localhost~] #cd php-7.1.6

4, create a directory for the installation of PHP

[Root@localhost php-7.1.6]# mkdir/usr/src/php

5, then execute the following instructions (must be in the PHP installation package directory to execute):

[Root@localhost php-7.1.6]#./configure--prefix=/usr/local/php--with-curl--with-freetype-dir--WITH-GD-- With-gettext--with-iconv-dir--with-kerberos--with-libdir=lib64--with-libxml-dir--with-mysqli-- With-pcre-regex--with-pdo-mysql--with-pdo-sqlite--with-pear--with-png-dir--with-xmlrpc- 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-xml--enable-zip

6. Make compilation and test

[Root@localhost php-7.1.6]# make

[Root@localhost php-7.1.6]# make Test

7, the previous step is not a problem to start the installation

[Root@localhost php-7.1.6]# make install

8, compile the installation after the completion of cleaning up the compiled file

[Root@localhost php-7.1.6]# make clean

9. Copy the Php.ini-production file in the source code directory (php-7.1.6) to the/usr/local/php/etc/directory and modify the file name to PHP.ini, as follows:

[Root@localhost php-7.1.6]# CP Php.ini-production/usr/local/php/etc/php.ini

10, create PHP-FPM configuration file php-fpm.conf file, the following operations:

[Root@localhost php-7.1.6]# cd/usr/local/php/etc/

[Root@localhost etc]# CP Php-fpm.conf.default php-fpm.conf

11. Create PHP-FPM Extended Profile www.conf, as follows:

[Root@localhost etc]# CD php-fpm.d/

[Root@localhost php-fpm.d]# CP Www.conf.default www.conf

12, create the PHP-FPM startup file and give executable permissions, as follows:

[Root@localhost PHP-FPM.D] #cd

[root@localhost~] #cd php-7.1.6

[Root@localhost php-7.1.6]# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM

[Root@localhost php-7.1.6]# chmod a+x/etc/init.d/php-fpm

13. Start PHP-FPM Service

[Root@localhost php-7.1.6]#/etc/init.d/php-fpm start

Starting php-fpm Done

The output information from the previous line indicates that the PHP-FPM has started successfully.

14, Test PHP-FPM, the following operations:

[Root@localhost php-7.1.6] #cd/usr/local/php/sbin

[Root@localhost sbin]#./php-fpm-t

[08-jul-2017 19:45:03] Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful

See the above output information in the "successful" on the OK.

15, configure default.conf files to Nginx support PHP (need to install a good nginx), the following operations:

[Root@localhost sbin]# vi/etc/nginx/conf.d/default.conf

The configuration file needs to be modified as shown in Figure 1:


Figure 1 16, save exit after modifying default.conf this profile as shown above. Use the directive netstat–ntl to see if Nginx and PHP-FPM are running, as shown in Figure 2:



Figure 2

If the TCP80 port does not appear, use the following instructions to open the Nginx service:

[Root@localhost sbin]# systemctl start Nginx

17, into the site root directory, a new test file named index.php.

[Root@localhost sbin]# cd/usr/share/nginx/html

[Root@localhost html]# ls

50x.html index.html

[Root@localhost html]# VI index.php

Copy the following code into index.php and save the Exit (: WQ):

<?php

Phpinfo ();

?>

18. Give executable permissions to files or folders under/usr/share/nginx/html

[Root@localhost html]# chmod–r 755/usr/share/nginx/html

19, open the browser test php,http://localhost/index.php as shown in Figure 3, PHP installed successfully.


Figure 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.