##安装依赖
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel
##编译php
./configure \ --prefix=/usr/local/php7 \ --exec-prefix=/usr/local/php7 \ --with-config-file-path=/usr/local/php7/etc \ --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 \ --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
##编译&安装
make && make install
##配置
cp php.ini-development /usr/local/php7/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm chmod +x /etc/init.d/php7-fpm cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf cp php-fpm.d/www.conf.default php-fpm.d/www.conf
##启动
/etc/init.d/php7-fpm start
#PHP安装常见错误:
错误1: configure: error: xml2-config not found
解决方法:
重新安装libxml2和libxml2-devel包
yum install libxml2
yum install libxml2-devel -y
错误2: configure: error: Cannot find OpenSSL's <evp.h>
解决方法:重新安装openssl-devel
yum install openssl openssl-devel
错误3:configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决方法:重新安装curl-devel
yum -y install curl-devel
yum -y install libjpeg-devel
yum install libpng-devel
yum install freetype-devel
yum install php-mcrypt libmcrypt libmcrypt-devel
yum install libxslt-devel* -y
以上问题均为缺少依赖
<br />