RedHat 7 安裝PHP

甲骨文技術支援發表於2018-02-23
1.作業系統版本

  1. [root@aws srclib]# cat /etc/redhat-release
  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/php-5.6.30.tar.gz
3.解壓

  1. tar -xzvf php-5.6.30.tar.gz
4.執行configure

  1. cd php-5.6.30
  2. ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --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
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 ""
6.上面的錯誤都解決後就可以編譯和安裝了

  1. make
  2. make install
7.最後複製檔案

  1. cp php.ini-production /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/




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20893244/viewspace-2151185/,如需轉載,請註明出處,否則將追究法律責任。

相關文章