去官網選擇合適的鏡像站點去下載源碼包:https://secure.php.net/get/php-7.3.0.tar.gz/from/a/mirror
cd /usr/local/src wget http://hk1.php.net/get/php-7.3.0.tar.gz/from/this/mirror tar -zxf php-7.3.0.tar.gz cd php-7.3.0 ./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-bcmath --enable-mbstring --with-gettext --enable-fpm --enable-shmop --enable-soap --enable-opcache --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar make && make install
安裝遇到的問題:
1.libzip安裝:官網找到最新的1.5.1:https://libzip.org/
yum -y remove libzip-devel yum -y install cmake wget https://libzip.org/download/libzip-1.5.1.tar.gz tar xvf libzip-1.5.1.tar.gz cd libzip-1.5.1 mkdir build cd build cmake .. make make install
2.configure: error: off_t undefined; check your library configuration:轉載於鏈接:https://segmentfault.com/q/1010000007346459
根據報錯信息分析 configure: error: off_t undefined; check your library configuration
未定義的類型 off_t。
off_t 類型是在 頭文件 unistd.h中定義的,在32位系統 編譯成 long int ,64位系統則編譯成 long long int ,這里題主的系統應該是 64位的吧,在進行編譯的時候 是默認查找64位的動態鏈接庫,但是默認情況下 centos 的動態鏈接庫配置文件/etc/ld.so.conf里並沒有加入搜索路徑,這個時候需要將 /usr/local/lib64 /usr/lib64 這些針對64位的庫文件路徑加進去。
# 添加搜索路徑到配置文件
echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v
(其中ldconfig -v 是用來更新ld的緩存文件 ld.so.cache , 緩存文件的目的是記錄動態編譯庫文件的路徑,加快二進制文件運行時的速度)
待驗證: ld默認搜索路徑應該是 /usr/local/lib /usr/lib ,這個待驗證
ld默認搜索路徑是 /usr/local/lib /usr/lib
