Centos7.6安裝php7.3.4

想把php由5.4.6改爲最新版。
首先卸載掉php5.4.6.

rpm -qa|grep php
yum -y remove php-5.4.6

上面是舉例,我先卸載了,沒法截圖了。
主要就是將所有5.4.6的都移除,
然後接下來是安裝。

wget https://downloads.php.net/~cmb/php-7.3/php-7.3.4.tar.gz
tar xzvf php-7.3.4.tar.gz
cd php-7.3.4

注意下載的時候不要用官網的download目錄直接下載,親測下載會失敗,要用/~cmb目錄下載。速度很快。

./configure --prefix=/data/nmp/php \
--with-config-file-path=/data/nmp/php/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-xml \
--enable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-fileinfo \
--enable-opcache \
--enable-maintainer-zts \
;

接下來就是編譯,因爲之前有安裝過5.4.6,所以只處理checking提示的依賴包的安裝。

configure: error: Please reinstall the BZip2 distribution

yum install bzip2 bzip2-devel
configure: error: Please reinstall the libzip distribution

yum install -y libzip-devel
[root@localhost php-7.3.4]# rpm -qa|grep libzip
libzip-0.10.1-8.el7.x86_64
libzip-devel-0.10.1-8.el7.x86_64

yum -y remove libzip
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build && cd build
cmake .. && make && make install

[root@localhost build]# cmake ..
CMake Error at CMakeLists.txt:4 (CMAKE_MINIMUM_REQUIRED):
  CMake 3.0.2 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!

不止libzip版本太低,發現cmake版本也過低。
注意回到/home/aggy目錄安裝,因爲cmake使用者不只是libzip

yum -y remove cmake
wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz

cd cmake-3.14.4
./bootstra
gmake
ln -s /usr/local/bin/cmake /usr/bin/

cmake和libzip的安裝都有點慢,耐心一點。安裝成功後繼續回到libzip的安裝。
如果你是和我一樣操作的話那麼你的libzip應該是在php文件下面。

cd /home/aggy/php-7.3.4/libzip-1.5.2/
mkdir build && cd build
cmake .. && make && make install

成功。
繼續./configure

configure: error: DBA: Could not find necessary header file(s).
yum install gdbm-devel

問題太多了,忍不住安裝一波依賴。

yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
configure: error: off_t undefined; check your library configuration

vi /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64

保存

esc鍵後輸入
:wq

運行,使之生效

ldconfig -v

再檢查一遍依賴。

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/phpdbg/phpdbg.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
make && make install

編譯安裝的時間有點長!

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM defconfig:     skipping
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - upgraded:  1.4.5
[PEAR] Console_Getopt - upgraded:  1.4.2
[PEAR] Structures_Graph- already installed: 1.1.1
pear/pear dependency package "pear/XML_Util" downloaded version 1.4.3 is not the recommended version 1.4.2, but may be compatible, use --force to install
pear/XML_Util cannot be installed, conflicts with installed packages
[PEAR] XML_Util       - upgraded:  1.4.3
[PEAR] PEAR           - upgraded:  1.10.9
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/aggy/php-7.3.4/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

他前面提示了make test
我們來測試一下。時間依然很長,一堆pass

這裏就是成功了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章