博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
安装PHP5、安装PHP7
阅读量:6307 次
发布时间:2019-06-22

本文共 5042 字,大约阅读时间需要 16 分钟。

hot3.png

php中mysql,mysqli,mysqlnd,pdo到底是什么

查看编译参数

PHP5安装

  • 进到src目录下 cd /usr/local/src
  • 下载PHP5源码包wget http://cn2.php.net/distributions/php-5.6.37.tar.gz
  • 解压下载的文件 tar -zxvf php-5.6.37.tar.gz
  • 进入文件目录 cd php-5.6.37
  • configure ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/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-zlib-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl-dir=/usr/include/openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  • 查看报错信息
checking for xml2-config path… configure: error: xml2-config not found. Please check your libxml2 installation.
  • 解决办法如下,完成后再执行configure
yum install libxml2-devel -y yum install libxml2 -y
  • 查看报错信息
configure:error: cannot find OpenSSL's 
  • 解决如下,完成后再执行configure时将--with-openssl 改为--with-openssl-dir=/usr/include/openssl。或者不更改命令,直接执行yum install -y openssl-devel 也可以。
export PHP_OPENSSL_DIR=yes
  • 查看报错信息
configure:error:please reinstall the BZip2 distribution
  • 解决如下,完成后继续configure
yum install bzip2-devel -y
  • 查看报错信息
configure:error:jpeglib.h not found
  • 解决如下,完成后继续configure
yum install libjpeg-devel -y
  • 查看报错信息
png.h  not found
  • 解决后继续configure
yum install libpng-devel
  • 查看报错信息
freetype-config not found
  • 解决后继续configure
yum install freetype-devel -y
  • 查看报错信息
mcrypt.h not found please reinstall libmcrypt
  • 解决后继续configure
yum install libmcrypt-devel -y

  • 出现这个界面就可以编译安装了
  • make && make install
  • 编译安装完之后需要拷贝一个文件做配置文件 ,源文件是在/usr/local/src/php-5.6.37下 ,cp php.ini-development /usr/local/php/etc/php.ini
  • 查看是否加载配置文件,该命令可以查看PHP信息,包括编译参数,configure路径等。
/usr/local/php/bin/php -i |less

安装PHP 7

PHP7和PHP5的安装大同小异

  • 进入/usr/local/src目录

  • wget

  • tar jxvf php-7.1.20.tar.bz2

  • cd php-7.1。20

  • ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php7/etc --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 --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

  • 因为之前装过PHP5,很多包已经安装了,所以这一步一般不会报错。

checking whether to build shared libraries... yeschecking whether to build static libraries... nocreating libtoolappending configuration tag "CXX" to libtoolGenerating filesconfigure: creating ./config.statuscreating main/internal_functions.ccreating main/internal_functions_cli.c+--------------------------------------------------------------------+| License:                                                           || This software is subject to the PHP License, available in this     || distribution in the file LICENSE.  By continuing this installation || process, you are bound by the terms of this license agreement.     || If you do not agree with the terms of this license, you must abort || the installation process at this point.                            |+--------------------------------------------------------------------+Thank you for using PHP.config.status: creating php7.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commandsconfigure: WARNING: unrecognized options: --with-freetype[root@localhost php-7.1.20]# echo $?0
  • make&&make install 编译安装
  • ls /usr/local/apache2.4/modules/libphp7.so
[root@localhost php-7.1.20]# cd /usr/local/apache/modules/[root@localhost modules]# lshttpd.exp             mod_authn_dbm.so        mod_cache.so          mod_headers.so              mod_proxy_ajp.so       mod_ratelimit.so         mod_socache_shmcb.solibphp5.so
  • cp php.ini-production /usr/local/php7/etc/php.ini
  • 安装完成后,可以使用/usr/local/apache2.4/bin/apachectl -M查看加载的模块,可以看到7和5都被加载了。-
[root@localhost php-7.1.20]# /usr/local/apache/bin/apachectl -M |grep phpAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message php5_module (shared) php7_module (shared)
  • 当一台机器上面装的既有5又有7的时候,如果想让Apache启动时加载7,就在配置文件中将5那一行注释掉 vi /usr/local/apache/conf/httpd.conf
#LoadModule php5_module        modules/libphp5.soLoadModule php7_module        modules/libphp7.so

注释掉5后发现不再加载PHP5了。

[root@localhost php-7.1.20]# /usr/local/apache/bin/apachectl -M |grep phpAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message php7_module (shared)

转载于:https://my.oschina.net/u/3731306/blog/1923513

你可能感兴趣的文章
oracle.jdbc.driver.OracleDriver和oracle.jdbc.OracleDriver这两个驱动的区别
查看>>
NSQ部署
查看>>
git常用命令记录
查看>>
IBM发布新一代云计算工具包MobileFirst Foundation
查看>>
唯品会HDFS性能挑战和优化实践
查看>>
大规模学习该如何权衡得失?解读NeurIPS 2018时间检验奖获奖论文
查看>>
大厂前端高频面试问题与答案精选
查看>>
我们用5分钟写了一个跨多端项目
查看>>
Visual Studio 15.4发布,新增多平台支持
查看>>
有赞透明多级缓存解决方案(TMC)设计思路
查看>>
如何设计高扩展的在线网页制作平台
查看>>
Git 2.5增加了工作树、改进了三角工作流、性能等诸多方面
查看>>
Swift 5将强制执行内存独占访问
查看>>
中台之上(二):为什么业务架构存在20多年,技术人员还觉得它有点虚?
查看>>
深度揭秘腾讯云低功耗广域物联网LPWAN 技术及应用
查看>>
与Jeff Sutherland谈敏捷领导力
查看>>
More than React(四)HTML也可以静态编译?
查看>>
React Native最佳学习模版- F8 App开源了
查看>>
云服务正在吞噬世界!
查看>>
阅读Android源码的一些姿势
查看>>