php安装

 

php

当前主流版本5.6/7.1

php5安装

  • cd /usr/src/local
  • wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
  • tar -zxvf php-5.6.30.tar.gz
  • cd php-5.6.30
  • ./configure —prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2.4/bin/apxs \
    --with-config-file-path=/usr/local/php5/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-exif

  • 以下每解决一个错误都重新编译,然后产生第二个错误,一个一个解决

“configure: error: libxml2 version 2.6.11 or greater required.”,前面装apr-util装过一次而且是比这个要新的,不知道为什么会识别不到
yum remove libxml2-devel;yum -y install libxml2-devel #重新安装
“configure: error: Cannot find OpenSSL’s “ yum -y install openssl-devel “通过yum list | grep openssl 查找”

“checking for zlib version >= 1.2.0.4… configure: error: libz version greater or equal to 1.2.0.4 required” 可以看到版本不够,然后查找发现版本比他新,没办法卸了重装试一下,果然解决了,不知道什么原因
“configure: error: xml2-config not found. Please check your libxml2 installation.” 这个我刚装过的呀,居然重装成功了估计是刚卸载了zlib引起的。
“configure: error: Cannot find OpenSSL’s “ yum -y install openssl-devel #同上
“configure: error: Please reinstall the BZip2 distribution” #终于除了个新的错误 老方法 yum list | grep bzip2,装devel包
“configure: error: jpeglib.h not found” yum provides jpeglib.h 看下这个文件依赖哪个包,居然没有结果 yum list | grep jpeglib
在试一试,还是没有 yum list | grep jpeg 搜索到了 凭直觉选一个安装 yum -y install openjpeg-devel 错了,google一下
查到 “jpeglib.h”在libjpeg中 所以 yum -y install libjpeg-turbo-devel.x86_64 安装
“configure: error: png.h not found.” yum -y install libpng-devel
“configure: error: freetype-config not found.” yum provides freetype-config; yum -y install freetype-devel
“configure: error: mcrypt.h not found. Please reinstall libmcrypt.”
“configure: WARNING: unrecognized options: —with-pnp-dir” 查一下是写错了 应该是 —with-png-dir,只是个警告,不过还是重新链接一下

注:一般devel后缀包都是供开发用,包含 “头文件” “链接库” 和一些开发文档以及演示代码

  • make && make test
  • make install

  • cp php.ini-production /usr/local/php5/etc/php.ini

Linux下查看Nginx、Napache、MySQL、PHP的编译参数的命令如下:

1、nginx编译参数:
#/usr/local/nginx/sbin/nginx -V
2、apache编译参数:
# cat /usr/local/apache/build/config.nice
3、php编译参数:
# /usr/local/php/bin/php -i |grep configure
4、mysql编译参数:
# cat /usr/local/mysql/bin/mysqlbug|grep configure

php7 安装

参数中把php5改成php7,其他参数一样 “configure: WARNING: unrecognized options: —with-mysql, —with-mcrypt, —enable-gd-native-ttf”
取消这几个参数然后链接。然后执行./configure …. 没有报错,前面php5应该把需要链接的库文件都装好了,所以装的很顺畅。

./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/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-dir \
--with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl \
--enable-soap --enable-mbstring --enable-sockets --enable-exif  \

--enable-fpm

 #--enable-fpm 在/etc下生成php-fpm

posted on 2017-12-19 07:12  游荡的鱼  阅读(312)  评论(0编辑  收藏  举报

导航