Centos6.5 install php 7
Create users and groups
Groupadd www
Useradd-g www
Usermod-s/sbin/nologin www
Install Components
Yum install-y libxml2 libxml2-devel libxml2-python curl-devel libjpeg-devel libpng libpng10 libpng10-devel libpng-devel freetype-devel libmcrypt-devel gd-devel
Clear Cache
Yum clean all
Download the latest php-7.0.6
Extract
Tar zxvf php-7.0.6.tar.gz-C/usr/src/
Cd/usr/src/php-7.0.6/
./Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc \
-- With-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib \
-- With-libxml-dir -- enable-xml -- enable-bcmath \
-- Enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl \
-- Enable-mbregex -- enable-fpm -- enable-mbstring \
-- With-mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash \
-- Enable-pcntl -- enable-sockets \
-- With-xmlrpc -- enable-zip -- enable-soap -- with-mysql-sock =/data/3306/mysqld. sock \
-- With-curl =/usr -- with-gettext -- with-iconv -- enable-mysqlnd \
-- With-mysqli = mysqlnd \
-- With-pdo-mysql = mysqlnd \
Install
Make
Make install
++
In particular, PHP 7 officially removed the mysql extension.
Use mysqlnd driver
If you continue to use the compilation method of the old version
-- With-mysql =/usr/local/mysql -- enable-embedded-mysqli -- with-mysqli =/usr/local/mysql/bin/mysql_config
An error is reported during make.
Make: *** [ext/mysqli/mysqli_embedded.lo] Error 1
So I changed
-- Enable-mysqlnd -- with-mysqli = mysqlnd -- with-pdo-mysql = mysqlnd
Can be compiled successfully
++ +
Copy the configuration file and startup script
Cp php. ini-production/usr/local/php/etc/php. ini
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Cp sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
Cp/usr/local/php/etc/php-fpm.d/www. conf. default/usr/local/php/etc/php-fpm.d/www. conf
Cd/usr/local/php/etc/php-fpm.d
Edit configuration file
Vi www. conf
Modify user and group to www
User = www
Group = www
Set the script permission and add it to auto-start upon startup.
Chmod + x/etc/init. d/php-fpm
Chkconfig -- add php-fpm
Chkconfig -- level 2345 php-fpm on
Start php-fpm
/Etc/init. d/php-fpm start
Check whether the port is enabled
Netstat-anpt | grep php-fpm
Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 25727/php-fpm