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

这里就是成功了。

编译 ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --with-mcrypt=/usr/local/apps/libmcrypt --disable-fileinfo 报错:1, **configure: error: system libzip must be upgraded to version >=**0.11。 使用Yum最新版只到0.10,不足以达到要求。 一、先删除libzip yum remove libzip -y SSH执行以上命令,先删除libzip 和 libzip-devel 二、下载安装并手动编译 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 三、(可忽略)另外最新版本请参考官网:https://nih.at/libzip/ 1.5.0的libzip需要cmake wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install 报错2: error: off_t undefined; check your library configuration 根据报错信息分析 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 再次执行 编译 成功 执行安装: make && make install 报错: /usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory 解决: cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h 1 安装成功: 复制配置文件: cp php.ini-production /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf ln -s /usr/local/php/sbin/php-fpm /usr/local/bin 修改配置: cd /usr/local/php/etc/php-fpm.d vim www.conf [www] //池子名 (pool) 设置 ;listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用本机ip listen.mode = 666 //sock 文件的权限 listen.owner = nobody listen.group = nobody user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024 加入 systemtl 服务: cd /usr/local/src/php-7.3.0beta1/sapi/fpm cp php-fpm.service /usr/lib/systemd/system/ 启动: systemctl start php-fpm systemctl status php-fpm -l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aggy阿吉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值