First, download the source package
Open the PHP website http://php.net/Click on the navigation bar downloads into the download page: http://php.net/downloads.php Download the version you want to install, here to download the latest version of the php-7.1.8 source package.
Download the Environment source package wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz can choose the version, here to download the latest version libiconv-1.15.tar.gz
Second, unzip the source package and install the environment package
Tar zxvf libiconv-1.15. tar.gz cd libiconv-1.15 . /configure--prefix=/usr/local/&& make install
Iii. adding users and groups running the PHP7 program
-G www www
Iv. Compiling and installing PHP7
tar zxvf php-7.1 . 8 .tar.gz cd php -7.1 . 8 /configure--PREFIX=/USR/LOCAL/PHP7--with-config-file-path=/usr/local/php7/etc--with-mcrypt--with-mysqli= Mysqlnd--with-pdo-mysql=mysqlnd--with-iconv=/usr/local/libiconv/--enable-xml--enable-bcmath-- Enable-inline-optimization--enable-mbregex--enable-fpm--with-openssl--with-xmlrpc--enable-zip--enable-soap-- Without-pear--enable-session--with-libxml-dir--with-zlib--with-curl--enable-dba--enable-ftp--with-freetype-dir --WITH-GD--with-jpeg-dir--with-png-dir--with-zlib-dir--enable-gd-native-ttf--with-gettext--enable-mbstring-- Enable-pcntl--without-pdo-sqlite--enable-shmop--enable-sockets--enable-sysvmsg--enable-sysvsem--ENABLE-SYSVSHM --enable-opcache
At this time, if the error, the general lack of environmental packages, according to the missing package for Yum installation
Yum-y install gcc g++ libxml2 libxml2-devel OpenSSL openssl-devel Curl curl-devel libjpeg libjpeg-devel libpng libpng-dev El freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel
In fact, there are more configuration items here than the above, you can use the ./configure--help command to see all the options, note that in PHP7 --with-mysql native support no longer exists and the operation becomes mysqli or PDO. These options are fully sufficient for normal PHP development, and you can choose to manually open the appropriate modules later if needed.
Then perform a compilation installation
Make && make install
The default installation path for PHP is specified as /usr/local/php7 , where the default installation path for the configuration file is /usr/local/php7/etc .
At this time there is no php.ini file in the installation directory, you need to unzip the package path under a copy to /usr/local/php7/etc , and renamed to PHP.ini .
cp/usr/local/src/php-7.1. 8/php.ini-development/usr/local/php7/etc/php.ini
Cp/usr/local/php7/etc/php-fpm.conf. default /usr/local/php7/etc/php-fpm.conf
cp/usr/local/src/php-7.1. 8/sapi/fpm/init.d.php-fpm/etc/init.d/php-+x/etc/init.d/php-fpm7/etc/init.d/php-fpm7 Start
At this point, it's almost ready to start. Then you modify the configuration file to suit your needs.
Vim/usr/local/php7/etc/php.ini
== off##### #在关闭display_errors后开启PHP错误日志 (Path in PHP-="/usr/local/ php7/lib/php/extensions/no-debug-non-zts-20141001/"= PRC
Modifying a configuration file php-fpm.conf
vim/usr/local/php7/etc/php-=/var/log/php-fpm/error.log##### #引入www configuration include in the. conf file =/USR/LOCAL/PHP7/ETC/PHP-FPM.D/*. conf
Www.conf This is an extended configuration file for the PHP-FPM process service
== www##### #根据nginx. conf in Configuration Fastcgi_pass UNIX:/dev/shm/php-127.0. 0.1:9000 =/dev/shm/php-==0660 =/var/log/php-fpm/$pool-= 10s
modifying Nginx configuration Files
Location ~ \.php$ { #fastcgi_pass 127.0. 0.1:9000; Fastcgi_pass Unix:/dev/shm/php-fpm7.sock; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include fastcgi_params; }
Because PHP7 has deprecated MySQL extensions to mysqli and mysqlpdo, but some programs require MySQL support to run, you can do this by installing the MySQL extension
V. Add extensions to PHP
First download the MySQL extension package on the PHP website: http://git.php.net/?p=pecl/database/mysql.git;a=summary Here is the latest version of the mysql-230a828.tar.gz, uploaded to the server
Then unzip the build installation
Tar zxvf mysql-230a828.tar.gzcd mysql-230a828# initialized with Phpize (phpize in php7 install directory)/usr/local/php7/bin /phpize# compile MySQL extension, use MySQL native driver as MySQL link library . /configure--with-php-config=/usr/local/php7/bin/php-config--with-mysql=mysqlnd && make Install
The path of a link library is obtained after the compilation and installation is successful
Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/
Edit PHP.ini File
Vim/usr/local/php7/etc/php.ini
Join the link library so file at the end
[mysql]extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/mysql.so
Finally overloaded PHP and Nginx services
/etc/init.d/php-fpm7 Reload/etc/init.d/nginx Reload
Access to test files index.php to view installation and installed extensions
<? php phpinfo ();? >
Similarly, additional extension modules can be installed as needed.
Centos6.8 source code Compilation installation PHP7