欢迎光临
我们一直在努力

RedHat 7 安装PHP

1.操作系统版本

  1. [root@aws srclib]# cat /etc/redhatrelease
  2. Red Hat Enterprise Linux Server release 7.4 (Maipo)

2.下载php安装包,本例是5.6.30版本

  1. cd /usr/local/src
  2. wget http://cn2.php.net/distributions/php5.6.30.tar.gz

3.解压

  1. tar xzvf php5.6.30.tar.gz

4.执行configure

  1. cd php5.6.30
  2. ./configure prefix=/usr/local/php withapxs2=/usr/local/apache2.4/bin/apxs withconfigfilepath=/usr/local/php/etc withlibxmldir withgd withjpegdir withpngdir withfreetypedir withiconvdir withzlibdir withbz2 withopenssl withmcrypt enablesoap enablegdnativettf enablembstring enablesockets enableexif

5.在configure过程中遇到6个错误,如下:

  1. 错误1:
    configure: error: xml2-config not found. Please check your libxml2 installation.
    解决办法:
    yum install -y libxml2-devel
    错误2:
    configure: error: Cannot find OpenSSL’s
    解决办法:
    yum install -y openssl openssl-devel
    错误3:
    configure: error: Please reinstall the BZip2 distribution
    解决办法:
    yum install -y bzip2 bzip2-devel
    错误4:
    configure: error: jpeglib.h not found.
    解决办法:
    yum install -y libjpeg libjpeg-devel
    错误5:
    configure: error: freetype-config not found.
    解决办法:
    yum install -y freetype freetype-devel
    错误6:
    configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    解决办法:
    yum install -y libmcrypt-devel

其中错误6,需要安装epel扩展yum源,安装方法如下:

  1. rpm ivh “http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm”

6.上面的错误都解决后就可以编译和安装了

  1. make
  2. make install

7.最后复制文件

  1. cp php.iniproduction /usr/local/php/etc/php.ini

8.测试是否正确解析php

  1. vi /usr/local/apache2.4/htdocs/mytest.php //写入如下内容
  2. <?php
  3.     echo “php测试正常”
  4. ?>

9.保存脚本后继续测试,如下:

  1. [root@aws srclib]# curl localhost/mytest.php
  2. php测试正常

10.查看PHP配置文件所在位置

  1. [root@aws srclib]# /usr/local/php/bin/php i |grep i “loaded configuration file”
  2. PHP Warning: Unknown: It is not safe to rely on the system‘s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC

欢迎访问我的另一篇文章,RedHat 7 安装httpd

http://blog.itpub.net/20893244/viewspace-2151184/

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。