對編譯安裝的PHP進行公升級

2021-08-01 09:51:22 字數 4344 閱讀 1484

準備依賴包和函式庫:

yum -yinstall gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetypefreetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-develcurl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-developenssl openssl-devel openldap openldap-devel nss_ldap openldap-clientsopenldap-servers patch perl-cpan pcre-devel pcre libxslt libxslt-devel php-mcrypt  libmcrypt libmcrypt-devel

解壓:tar -zxvf  php-5.6.3.tar.gz  

檢查配置環境(通用於7.0):

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir=/usr/local --with-jpeg-dir --with-kerberos --with-ldap --with-ldap-sasl --with-libdir=lib64 --with-libxml-dir=/usr/lib64 --with-mcrypt --with-mhash --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pcre-regex=/usr --with-pdo-mysql=mysqlnd --with-pdo-sqlite=shared --with-pear=/usr/local/lib/php --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath --enable-opcache  --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath --enable-opcache --disable-debug --enable-shared --enable-ftp --enable-session --enable-fastcgi --disable-fileinfo --with-fpm-user=username --with-fpm-group=username

配置詳解:

--with-mysql-sock=/var/run/mysql/mysql.sock  //mysql的sock檔案

--with-iconv-dir=/usr/local    //iconv庫檔案,編譯安裝icon庫時需要指定路徑

--with-fpm-user=username--with-fpm-group=username     //指定php-fpm的使用者和組

configure: error:mcrypt.h not found.

報錯內容:

configure: error: mcrypt.h notfound. please reinstall libmcrypt

yum install  php-mcrypt  libmcrypt  libmcrypt-devel

編譯安裝:

ln-s /usr/local/lib/libiconv.so.2 /usr/lib64/

make zend_extra_libs='-liconv'

報錯:

collect2: ld returned 1 exit status  

make: *** [sapi/cli/php] error 1  

解釋:在安裝

php

到系統中時要是發生「

undefined reference to libiconv_open'

」之類的錯誤資訊,那表示在「

./configure

」沒抓好一些環境變數值。錯誤發生點在建立「

-o sapi/cli/php

」是出錯,沒給到要

link

的iconv

函式庫引數。

解決方法: 編輯

makefile

大約100

行左右的地方

: extra_libs = ..... -lcrypt

在最後加上

-liconv

,例如: extra_libs = ..... -lcrypt-liconv然後重新再次

make

即可。

然後重新

make

順利通過了

編譯安裝

php

的時候,

執行make

報錯誤

錯誤:make: *** [ext/mysqli/mysqli.lo] error 1

[[email protected]]# mkdir /usr/local/webserver/mysql/include/mysql

[[email protected]]# ln -s /usr/local/webserver/mysql/include/*/usr/local/webserver/mysql/include/mysql

[root@localhost php-5.4.9]# make zend_extra_libs='-liconv'

拋錯:generating phar.phar

/usr/local/src/php-5.4.9/sapi/cli/php:error while loading shared libraries: libiconv.so.2: cannot open shared objectfile: no such file or directory

make: *** [ext/phar/phar.php] error 127

解決的方法如下:

#vi /etc/ld.so.conf

在裡面加上一行

/usr/local/lib

/usr/lib64

/usr/lib 2.

然後執行

/sbin/ldconfig

#/sbin/ldconfig 編譯

make

#makezend_extra_libs='-liconv'

拋錯:

generating phar.phar

chmod: cannot access `ext/phar/phar.phar': no such file or directory

make: [ext/phar/phar.phar] error 1 (ignored)

build complete.

don't forget to run 'make test'.

此處可以忽略

不過解決辦法如下

#cd  ext/phar/

#cp ./phar.php  ./phar.phar

然後到php5.4

資料夾

#makezend_extra_libs='-liconv'

#make test

#make install

make clean

make zend_extra_libs='-liconv'  

make install

準備配置檔案:

cp php.ini-production/usr/local/webserver/php-d/php-5.5.0/etc/php.ini

剩下的根據個人配置 配置,php.ini中的模組設定和php-fpm中的程序池配置按照原先的配置配置。

對已經編譯安裝的php新增curl,redis擴充套件

對於已經編譯安裝了的php新增擴充套件,使用phpize。官網解釋 擴充套件安裝步驟 cd extname extname為已經解壓的擴充套件源程式 phpize 要寫絕對路徑,一般在 usr local php bin phpize configure 預編譯 一般指定php config,新增 ...

安裝 XHGui對 PHP 應用進行效能診斷

profiling是一項用來觀察程式效能的技術,非常適用於發現程式的瓶頸或者緊張的資源。profiling能夠深入程式的內部,展現request處理過程中每一部分 的效能 同時,也可以確定有問題的請求 request 對於有問題的請求,我們還可以確定效能問題發生在請求內部的位置。對於php,我們有多...

PHP的編譯安裝

php編譯安裝 cd usr local src wget tar jxvf php 5.5.26.tar.bz2 cd php 5.5.26 configure with config file path usr local php etc with mysql usr local mysql 說...