ubuntu14.04編譯安裝PHP7

ubuntu14.04編譯安裝PHP7

  1. 下載安裝包 
    wget http://mirrors.sohu.com/php/php-7.0.16.tar.gz
  2. 解壓 
    tar zxvf php-7.0.16.tar.gz
  3. 進行配置以前安裝必要的包,不然會出現下面的一些問題 
    • sudo apt-get install libxml2-dev openssl libssl-dev curl libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6 libfreetype6-dev libmcrypt4 libmcrypt-dev
  4. 配置 
    • cd php-7.0.16
    • sudo ./configure --prefix=/usr/local/php \ 
      --with-config-file-path=/usr/local/php/etc \ 
      --enable-fpm --with-fpm-user=www-data \ 
      --with-pdo-mysql=mysqlnd \ 
      --with-libxml-dir --with-gd \ 
      --with-jpeg-dir --with-png-dir \ 
      --with-freetype-dir --with-iconv-dir --with-zlib-dir \ 
      --with-mcrypt --enable-soap --enable-gd-native-ttf \ 
      --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 \ 
      --with-pear --with-curl --with-openssl
  5. 編譯 
    • make
  6. 安裝 
    • make install
  7. 修改配置文件 
    cp php.ini-production /usr/local/php/etc/php.ini
  8. 使用php-fpm方式運行的設置 
    配置php-fpm 
    cd /usr/local/php/etc 
    cp php-fpm.conf.default php-fpm.conf 
    cp php-fpm.d/www.conf.default php-fpm.d/www.conf 
    啓動php-fpm 
    sudo /usr/local/php/sbin/php-fpm

配置過程當中可能遇到的錯誤:

  1. configure: error: xml2-config not found. Please check your libxml2 installation. 
    解決: 
    sudo apt-get install libxml2-dev
  2. configure: error: Cannot find OpenSSL’s libraries 
    解決: 
    sudo apt-get install openssl libssl-dev 
    若是已經安裝,libssl.so文件一般會在只會在/usr/lib/x86_64-linux-gnu/libssl.so,而系統只會去/usr/lib下尋找libssl.so文件,因此: 
    ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib
  3. configure: error: Please reinstall the libcurl distribution - 
    easy.h should be in /include/curl/ 
    解決: 
    sudo apt-get install curl libcurl4-gnutls-dev
  4. configure: error: jpeglib.h not found. 
    解決: 
    sudo apt-get install libjpeg-dev
  5. configure: error: png.h not found. 
    解決: 
    sudo apt-get install libpng12-dev
  6. configure: error: freetype-config not found. 
    解決: 
    sudo apt-get install libfreetype6 libfreetype6-dev
  7. configure: error: mcrypt.h not found. Please reinstall libmcrypt. 
    解決: 
    sudo apt-get install libmcrypt4 libmcrypt-dev

注:配置過程當中出現的問題基本是缺乏包,或者是找不到包文件php

相關文章
相關標籤/搜索