-11.10/11.11/11.12安装PHP5-11.13安装PHP7-扩展-php中mysql,mysqli,mysqlnd,pdo到底是什么-http://blog.csdn.net/u013785951/article/details/60876816-查看编译参数http://ask.apelearn.com/question/1295#11.10安装PHP5上-PHP官网www.php.net-当前主流版本为5.6/7.11.cd/usr/local/src/2.wgethttp://cn2.php.net/distributions/php-5.6.30.tar.gz3.tarzxfphp-5.6.30.tar.gz4.cdphp-5.6.305../configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif6.make&&makeinstall7.cpphp.ini-production/usr/local/php/etc/php.ini```[root@aminglinux-001~]#cd/usr/local/src[root@aminglinux-001src]#wgethttp://cn2.php.net/distributions/php-5.6.30.tar.bz2--2017-09-2721:39:15--http://cn2.php.net/distributions/php-5.6.30.tar.bz2正在解析主机cn2.php.net(cn2.php.net)...202.108.35.250,202.108.35.235正在连接cn2.php.net(cn2.php.net)|202.108.35.250|:80...已连接。已发出HTTP请求,正在等待回应...200OK长度:15011816(14M)[application/octet-stream]正在保存至:“php-5.6.30.tar.bz2”100%[====================================================>]15,011,816880KB/s用时19s2017-09-2721:39:35(756KB/s)-已保存“php-5.6.30.tar.bz2”[15011816/15011816])[root@aminglinux-001src]#du-shphp-5.6.30.tar.bz215Mphp-5.6.30.tar.bz2[root@aminglinux-001src]#```-先解压```[root@aminglinux-001src]#tarjxvfphp-5.6.30.tar.bz2php-5.6.30/server-tests.phpphp-5.6.30/php.ini-developmentphp-5.6.30/EXTENSIONSphp-5.6.30/README.namespacesphp-5.6.30/pear/php-5.6.30/pear/install-pear.txtphp-5.6.30/pear/install-pear-nozlib.pharphp-5.6.30/pear/fetch.phpphp-5.6.30/pear/Makefile.fragphp-5.6.30/README.SUBMITTING_PATCH[root@aminglinux-001src]#```-编译---with-apxs2=/usr/local/apache2.4/bin/apxs指定apache的---with-mysql=/usr/local/mysql指定mysql的(PHP7用不到这个)---with-mysqli=/usr/local/mysql/bin/mysql_config指定mysql的```[root@aminglinux-001src]#cdphp-5.6.30/[root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifConfiguringextensionscheckingsizeoflong...(cached)8checkingsizeofint...(cached)4checkingforint32_t...yescheckingforuint32_t...yescheckingforsys/types.h...(cached)yescheckingforinttypes.h...(cached)yescheckingforstdint.h...(cached)yescheckingforstring.h...(cached)yescheckingforstdlib.h...(cached)yescheckingforstrtoll...yescheckingforatoll...yescheckingforstrftime...(cached)yescheckingwhichregexlibrarytouse...phpcheckingwhethertoenableLIBXMLsupport...yescheckinglibxml2installdir...yescheckingforxml2-configpath...configure:error:xml2-confignotfound.Pleasecheckyourlibxml2installation.[root@aminglinux-001php-5.6.30]#这里报错了,运行echo$?[root@aminglinux-001php-5.6.30]#echo$?1[root@aminglinux-001php-5.6.30]#echo$?0[root@aminglinux-001php-5.6.30]#```-configure:error:xml2-confignotfound.Pleasecheckyourlibxml2installation.搜下xml2```[root@aminglinux-001php-5.6.30]#yumlist|grepxml2libxml2.x86_642.9.1-6.el7_2.3@anacondalibxml2.i6862.9.1-6.el7_2.3baselibxml2-devel.i6862.9.1-6.el7_2.3baselibxml2-devel.x86_642.9.1-6.el7_2.3baselibxml2-python.x86_642.9.1-6.el7_2.3baselibxml2-static.i6862.9.1-6.el7_2.3baselibxml2-static.x86_642.9.1-6.el7_2.3basemingw32-libxml2.noarch2.9.3-1.el7epelmingw32-libxml2-static.noarch2.9.3-1.el7epelmingw64-libxml2.noarch2.9.3-1.el7epelmingw64-libxml2-static.noarch2.9.3-1.el7epelpython-xml2rfc.noarch2.5.2-2.el7epeltinyxml2.x86_642.1.0-2.20140406git6ee53e7.el7epeltinyxml2-devel.x86_642.1.0-2.20140406git6ee53e7.el7epelxml2.x86_640.5-7.el7epel[root@aminglinux-001php-5.6.30]#```-我们需要的库一帮都是-devel的包```[root@aminglinux-001php-5.6.30]#yuminstall-ylibxml2-devel已安装:libxml2-devel.x86_640:2.9.1-6.el7_2.3作为依赖被安装:xz-devel.x86_640:5.2.2-1.el7zlib-devel.x86_640:1.2.7-17.el7完毕!完了再次编译,[root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifcheckingwhethertousesystemdefaultcipherlistinsteadofhardcodedvalue...nocheckingforDSA_get_default_methodin-lssl...nocheckingforX509_freein-lcrypto...nocheckingforRAND_egd...nocheckingforpkg-config.../usr/bin/pkg-configconfigure:error:CannotfindOpenSSL‘s<evp.h>[root@aminglinux-001php-5.6.30]#```-这里又报错了configure:error:CannotfindOpenSSL‘s<evp.h>```[root@aminglinux-001php-5.6.30]#yuminstall-yopenssl-devel已安装:openssl-devel.x86_641:1.0.2k-8.el7作为依赖被安装:keyutils-libs-devel.x86_640:1.5.8-3.el7krb5-devel.x86_640:1.15.1-8.el7libcom_err-devel.x86_640:1.42.9-10.el7libkadm5.x86_640:1.15.1-8.el7libselinux-devel.x86_640:2.5-11.el7libsepol-devel.x86_640:2.5-6.el7libverto-devel.x86_640:0.2.5-4.el7作为依赖被升级:e2fsprogs.x86_640:1.42.9-10.el7e2fsprogs-libs.x86_640:1.42.9-10.el7krb5-libs.x86_640:1.15.1-8.el7libcom_err.x86_640:1.42.9-10.el7libselinux.x86_640:2.5-11.el7libselinux-python.x86_640:2.5-11.el7libselinux-utils.x86_640:2.5-11.el7libss.x86_640:1.42.9-10.el7openssl.x86_641:1.0.2k-8.el7openssl-libs.x86_641:1.0.2k-8.el7完毕![root@aminglinux-001php-5.6.30]#再继续编译./configure完毕![root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifcheckingforgzgetsin-lz...yescheckingwhethertoenablebcstyleprecisionmathfunctions...nocheckingforBZip2support...yescheckingforBZip2indefaultpath...notfoundconfigure:error:PleasereinstalltheBZip2distribution[root@aminglinux-001php-5.6.30]#```-又出来一个新的错误configure:error:PleasereinstalltheBZip2distribution#11.11安装PHP5中-继续上面的错误configure:error:PleasereinstalltheBZip2distribution```checkingforBZip2support...yescheckingforBZip2indefaultpath...notfoundconfigure:error:PleasereinstalltheBZip2distribution[root@aminglinux-001php-5.6.30]#yuminstall-ybzip2-devel已安装:bzip2-devel.x86_640:1.0.6-13.el7完毕![root@aminglinux-001php-5.6.30]#```-再来继续编译./configure```[root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifcheckingwhethertoenabletruetypestringfunctioninGD...yescheckingwhethertoenableJIS-mappedJapanesefontsupportinGD...noIfconfigurefailstry--with-vpx-dir=<DIR>configure:error:jpeglib.hnotfound.[root@aminglinux-001php-5.6.30]#```-又出错了error:jpeglib.hnotfound.```[root@aminglinux-001php-5.6.30]#yuminstall-ylibjpeg-devel已安装:libjpeg-turbo-devel.x86_640:1.2.90-5.el7完毕![root@aminglinux-001php-5.6.30]#```-再继续编译./configure```[root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifIfconfigurefailstry--with-vpx-dir=<DIR>checkingforjpeg_read_headerin-ljpeg...yesconfigure:error:png.hnotfound.[root@aminglinux-001php-5.6.30]#Ifconfigurefailstry--with-vpx-dir=<DIR>checkingforjpeg_read_headerin-ljpeg...yesconfigure:error:png.hnotfound.[root@aminglinux-001php-5.6.30]#```-又报错了error:png.hnotfound,这次是要安装png```[root@aminglinux-001php-5.6.30]#yuminstall-ylibpng-devel已安装:libpng-devel.x86_642:1.5.13-7.el7_2完毕![root@aminglinux-001php-5.6.30]#```-继续```完毕![root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifIfconfigurefailstry--with-xpm-dir=<DIR>configure:error:freetype-confignotfound.[root@aminglinux-001php-5.6.30]#```-又报错error:freetype-confignotfound```[root@aminglinux-001php-5.6.30]#yuminstall-yfreetype-devel已安装:freetype-devel.x86_640:2.4.11-15.el7作为依赖被升级:freetype.x86_640:2.4.11-15.el7完毕![root@aminglinux-001php-5.6.30]#```-继续./configure```完毕![root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifcheckingforstdarg.h...(cached)yescheckingformcryptsupport...yesconfigure:error:mcrypt.hnotfound.Pleasereinstalllibmcrypt.[root@aminglinux-001php-5.6.30]#```-又报错了error:mcrypt.hnotfound.Pleasereinstalllibmcrypt.-安装这个mcrypt,mcrypt库在epel扩展源里面,所以想要安装mcrypt先需要先安装epel扩展源(yuminstallepel-release),```[root@aminglinux-001php-5.6.30]#yuminstalllibmcrypt-devel依赖关系解决================================================================================================Package架构版本源大小================================================================================================正在安装:libmcrypt-develx86_642.5.8-13.el7epel13k为依赖而安装:libmcryptx86_642.5.8-13.el7epel99k事务概要================================================================================================安装1软件包(+1依赖软件包)总下载量:112k安装大小:302kIsthisok[y/d/N]:y已安装:libmcrypt-devel.x86_640:2.5.8-13.el7作为依赖被安装:libmcrypt.x86_640:2.5.8-13.el7完毕![root@aminglinux-001php-5.6.30]#```-再来一次```[root@aminglinux-001php-5.6.30]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exifcreatinglibtoolappendingconfigurationtag"CXX"tolibtoolGeneratingfilesconfigure:creating./config.statuscreatingmain/internal_functions.ccreatingmain/internal_functions_cli.c+--------------------------------------------------------------------+|License:||ThissoftwareissubjecttothePHPLicense,availableinthis||distributioninthefileLICENSE.Bycontinuingthisinstallation||process,youareboundbythetermsofthislicenseagreement.||Ifyoudonotagreewiththetermsofthislicense,youmustabort||theinstallationprocessatthispoint.|+--------------------------------------------------------------------+ThankyouforusingPHP.config.status:creatingphp5.specconfig.status:creatingmain/build-defs.hconfig.status:creatingscripts/phpizeconfig.status:creatingscripts/man1/phpize.1config.status:creatingscripts/php-configconfig.status:creatingscripts/man1/php-config.1config.status:creatingsapi/cli/php.1config.status:creatingsapi/cgi/php-cgi.1config.status:creatingext/phar/phar.1config.status:creatingext/phar/phar.phar.1config.status:creatingmain/php_config.hconfig.status:executingdefaultcommands[root@aminglinux-001php-5.6.30]#[root@aminglinux-001php-5.6.30]#echo$?0[root@aminglinux-001php-5.6.30]#```-成功了!-下一步接着就是make这一步花费的时间长一点#11.12安装PHP5下```[root@aminglinux-001php-5.6.30]#makeGeneratingphar.phpGeneratingphar.pharPEARpackagePHP_Archivenotinstalled:generatedpharwillrequirePHP‘spharextensionbeenabled.clicommand.incdirectorytreeiterator.incinvertedregexiterator.incdirectorygraphiterator.incpharcommand.incphar.incBuildcomplete.Don‘tforgettorun‘maketest‘.[root@aminglinux-001php-5.6.30]#```-最后一步makeinstall```Buildcomplete.Don‘tforgettorun‘maketest‘.[root@aminglinux-001php-5.6.30]#makeinstallWrotePEARsystemconfigfileat:/usr/local/php/etc/pear.confYoumaywanttoadd:/usr/local/php/lib/phptoyourphp.iniinclude_path/usr/local/src/php-5.6.30/build/shtoolinstall-cext/phar/phar.phar/usr/local/php/binln-s-fphar.phar/usr/local/php/bin/pharInstallingPDOheaders:/usr/local/php/include/php/ext/pdo/[root@aminglinux-001php-5.6.30]#```-看下php的目录```[root@aminglinux-001php-5.6.30]#ls/usr/local/php/binetcincludelibphp核心的二进制文件[root@aminglinux-001php-5.6.30]#ls/usr/local/php/bin/pearpeardevpeclpharphar.pharphpphp-cgiphp-configphpize[root@aminglinux-001php-5.6.30]#du-sh/usr/local/php/bin/php36M/usr/local/php/bin/php[root@aminglinux-001php-5.6.30]#``````[root@aminglinux-001php-5.6.30]#du-sh/usr/local/apache2.4/modules/libphp5.so37M/usr/local/apache2.4/modules/libphp5.so[root@aminglinux-001php-5.6.30]#```-这个/usr/local/apache2.4/modules/libphp5.so就是我们想要的模块,php和apache结合起来是通过这个文件实现的-看一看php所加载的模块都有哪些,查看它加载模块的一个命令,这全是静态的-/usr/local/php/bin/php-m这个和httpd-M类似的功能```[root@aminglinux-001php-5.6.30]#/usr/local/php/bin/php-m[PHPModules]bz2CorectypedatedomeregexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqlmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[ZendModules][root@aminglinux-001php-5.6.30]#```-那php需不需要启动?php作为apache的模块存在的,看看apache的模块```[root@aminglinux-001php-5.6.30]#/usr/local/apache2.4/bin/httpd-MAH00558:httpd:Couldnotreliablydeterminetheserver‘sfullyqualifieddomainname,usingfe80::a152:bbdf:8b2b:db9b.Setthe‘ServerName‘directivegloballytosuppressthismessageLoadedModules:core_module(static)so_module(static)http_module(static)mpm_event_module(static)authn_file_module(shared)authn_core_module(shared)authz_host_module(shared)authz_groupfile_module(shared)authz_user_module(shared)authz_core_module(shared)access_compat_module(shared)auth_basic_module(shared)reqtimeout_module(shared)filter_module(shared)mime_module(shared)log_config_module(shared)env_module(shared)headers_module(shared)setenvif_module(shared)version_module(shared)unixd_module(shared)status_module(shared)autoindex_module(shared)dir_module(shared)alias_module(shared)[root@aminglinux-001php-5.6.30]#```-这个就是它的模块文件```[root@aminglinux-001php-5.6.30]#ls-l/usr/local/apache2.4/modules/libphp5.so-rwxr-xr-x1rootroot377526969月2722:45/usr/local/apache2.4/modules/libphp5.so[root@aminglinux-001php