新增系统用户组和用户:

下载 PHP7.3.5

[root@localhost ~]# mkdir devdir

[root@localhost ~]# cd devdir/

[root@localhost devdir]# wget https://www.php.net/distributions/php-7.3.5.tar.gz

-bash: wget: 未找到命令

[root@localhost devdir]# rpm -qa|grep wget

[root@localhost devdir]# yum -y install wget

[root@localhost devdir]# rpm -qa|grep wget

wget-1.14-18.el7.x86_64

下载PHP7 解压 编译

wget -c https://downloads.php.net/~cmb/php-7.3.4.tar.gz


编译参数解释

--with-fpm-user=webu --with-fpm-group=webg 添加PHP运行用户和用户组

./configure --prefix=/usr/local/php --with-fpm-user=webu --with-fpm-group=webg --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-MySQLi --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm

配置信息出错:

configure: error: in `/root/devdir/php-7.3.4':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details[root@localhost php-7.3.4]# vim config.log

下载gcc软件编译器 yum install -y gcc

configure: error: libxml2 not found. Please check your libxml2 installation.

checking for pkg-config... /usr/bin/pkg-configconfigure: error: libxml2 not found. Please check your libxml2 installation.[root@localhost php-7.3.4]# rpm -qa|grep libxml2libxml2-2.9.1-6.el7_2.3.x86_64[root@localhost php-7.3.4]# [root@localhost php-7.3.4]# yum install -y libxml2-develchecking for pkg-config... /usr/bin/pkg-configconfigure: error: Cannot find OpenSSL's [root@localhost php-7.3.4]# rpm -qa|grep opensslopenssl-1.0.2k-16.el7.x86_64openssl-libs-1.0.2k-16.el7.x86_64[root@localhost php-7.3.4]# yum install -y openssl-devel已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.nwsuaf.edu.cn * extras: mirror.lzu.edu.cnchecking for BZip2 in default path... not foundconfigure: error: Please reinstall the BZip2 distribution[root@localhost php-7.3.4]# yum install -y bzip2-devel已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.163.comchecking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support[root@localhost php-7.3.4]# rpm -qa|grep curlcurl-7.29.0-51.el7.x86_64libcurl-7.29.0-51.el7.x86_64Python-pycurl-7.19.0-19.el7.x86_64[root@localhost php-7.3.4]# yum install -y curl-devel已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.nwsuaf.edu.cn * extras: mirrors.cn99.comchecking whether to enable JIS-mApped Japanese font support in GD... noIf configure fails try --with-webp-dir=

configure: error: jpeglib.h not found.[root@localhost php-7.3.4]# yum install -y libjpeg-devel已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.nwsuaf.edu.cnconfigure: error: png.h not found.[root@localhost php-7.3.4]# yum install -y libpng-devel已加载插件:fastestmirrorIf configure fails try --with-xpm-dir=configure: error: freetype-config not found.[root@localhost php-7.3.4]# yum install -y freetype-devel已加载插件:fastestmirrorconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution[root@localhost php-7.3.4]# yum install -y libxslt-devel已加载插件:fastestmirrorconfigure: error: Please reinstall the libzip distribution[root@localhost php-7.3.4]# rpm -qa|grep libzip[root@localhost php-7.3.4]# yum install -y libzip已加载插件:fastestmirror[root@localhost php-7.3.4]# rpm -qa|grep libziplibzip-0.10.1-8.el7.x86_64[root@localhost php-7.3.4]# yum install -y libzip-devel已加载插件:fastestmirrorchecking for libzip... configure: error: system libzip must be upgraded to version >= 0.11[root@localhost php-7.3.4]#

下载libzip-1.5.2.tar.gz

https://libzip.org/download/libzip-1.5.2.tar.gz

[root@localhost devdir]# pwd/root/devdir[root@localhost devdir]# wget -c https://libzip.org/download/libzip-1.5.2.tar.gz--2019-05-09 15:02:31-- https://libzip.org/download/libzip-1.5.2.tar.gz正在解析主机 libzip.org (libzip.org)... 5.2.73.210, 2a04:52c0:101:2e6::de6c正在连接 libzip.org (libzip.org)|5.2.73.210|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:1203524 (1.1M) [application/x-gzip]正在保存至: “libzip-1.5.2.tar.gz”100%[======================================>] 1,203,524 44.8KB/s 用时 36s 2019-05-09 15:03:14 (32.8 KB/s) - 已保存 “libzip-1.5.2.tar.gz” [1203524/1203524])[root@localhost devdir]# tar zxvf libzip-1.5.2.tar.gz libzip-1.5.2/[root@localhost libzip-1.5.2]# lsAPI-CHANGES.md CMakeLists.txt INSTALL.md man srcappveyor.yml cmake-zipconf.h.in lib NEWS.md THANKSAUTHORS examples libzip.pc.in README.md TODO.mdcmake-config.h.in FindNettle.cmake LICENSE regress[root@localhost libzip-1.5.2]# mkdir build && cd build[root@localhost build]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/libzip ..-bash: cmake: 未找到命令[root@localhost build]# yum install -y cmake 【版本太低所以安装cmake最新版】[root@localhost build]# rm -f CMakeCache.txt [root@localhost build]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/libzip ..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![root@localhost build]# yum remove -y cmake已加载插件:fastestmirror[root@localhost devdir]# wget -c https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz[root@localhost devdir]# tar -zxvf cmake-3.14.3.tar.gz[root@localhost devdir]# cd cmake-3.14.3[root@localhost cmake-3.14.3]# ./configure ---------------------------------------------CMake 3.14.3, Copyright 2000-2019 Kitware, Inc. and ContributorsC compiler on this system is: cc ---------------------------------------------Error when bootstrapping CMake:Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.Please specify one using environment variable CXX.[root@localhost cmake-3.14.3]# yum install -y gcc-c++ 【安装gcc-c++编译环境】[root@localhost cmake-3.14.3]# ./bootstrap [root@localhost cmake-3.14.3]# gmake &&gmake install[root@localhost cmake-3.14.3]# which cmake/usr/local/bin/cmake[root@localhost cmake-3.14.3]# cmake --version-bash: /usr/bin/cmake: 没有那个文件或目录[root@localhost cmake-3.14.3]# cmake-bash: /usr/bin/cmake: 没有那个文件或目录[root@localhost cmake-3.14.3]# vim /etc/profile文件末尾 PATH="$PATH=/usr/local/bin" export PATH[root@localhost cmake-3.14.3]# source /etc/profile[root@localhost cmake-3.14.3]# cmake --versioncmake version 3.14.3CMake suite maintained and supported by Kitware (kitware.com/cmake).[root@localhost cmake-3.14.3]#

解决libzip 和cmake版本问题

重新配置PHP7编译环境参数

checking for libzip... not foundconfigure: error: Please reinstall the libzip distribution[root@localhost php-7.3.4]# yum -y install libzip-develchecking for pkg-config... (cached) /usr/bin/pkg-configchecking for libzip... configure: error: system libzip must be upgraded to version >= 0.11[root@localhost php-7.3.4]# which libzip/usr/bin/which: no libzip in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/bin:/root/bin)[root@localhost php-7.3.4]# ll /usr/local/liblib/ lib64/ libexec/ libzip/ [root@localhost php-7.3.4]# ll /usr/local/libzip/bin/ include/ lib64/ share/ [root@localhost php-7.3.4]# ll /usr/local/libzip/bin/zipzipcmp zipmerge ziptool [root@localhost php-7.3.4]# ll /usr/local/libzip/bin总用量 80-rwxr-xr-x. 1 root root 24392 5月 9 16:04 zipcmp-rwxr-xr-x. 1 root root 18880 5月 9 16:04 zipmerge-rwxr-xr-x. 1 root root 34928 5月 9 16:04 ziptool[root@localhost php-7.3.4]# vim /etc/profileunset iPATH="$PATH:/usr/local/bin:/usr/local/libzip/bin"export PATH[root@localhost php-7.3.4]# source /etc/profile[root@localhost php-7.3.4]#

libzip-1.5.2 无法安装,已经取消了。

/root/devdir/libzip-1.5.2/build[root@localhost build]# cd ../../[root@localhost devdir]# wget -c https://nih.at/libzip/libzip-1.2.0.tar.gz[root@localhost devdir]# tar -zxvf libzip-1.2.0.tar.gz [root@localhost devdir]# cd libzip-1.2.0[root@localhost libzip-1.2.0]# lsaclocal.m4 config.sub libzip-uninstalled.pc.in README.mdAPI-CHANGES configure LICENSE regressAUTHORS configure.ac ltmain.sh srccmake-config.h.in depcomp m4 test-driverCMakeLists.txt examples Makefile.am THANKScmake-zipconf.h.in INSTALL Makefile.in TODO.mdcompile install-sh man xcodeconfig.guess lib missingconfig.h.in libzip.pc.in NEWS.md[root@localhost libzip-1.2.0]# ./configure [root@localhost libzip-1.2.0]# make -j4 &&make install【最终解决方案】cp ../libzip-1.5.2/build/lib/libzip.so /lib64/

提示off_t类型没有定义 undefind,解决方法:

[root@localhost ~]# cd devdir/php-7.3.4[root@localhost php-7.3.4]# vim /etc/ld.so.confld.so.conf ld.so.conf.d/ [root@localhost php-7.3.4]# vim /etc/ld.so.conf[root@localhost php-7.3.4]# vim /usr/lib64/Display all 588 possibilities? (y or n)[root@localhost php-7.3.4]# vim /usr/lib64/lDisplay all 538 possibilities? (y or n)[root@localhost php-7.3.4]# vim /usr/lib64/libDisplay all 535 possibilities? (y or n)[root@localhost php-7.3.4]# vim /etc/ld.so.confinclude ld.so.conf.d/*.conf/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64[root@localhost php-7.3.4]# ldconfig -vldconfig: 多次给出路径“/lib”

编译安装

In file included from /root/devdir/php-7.3.4/ext/zip/php_zip.h:31:0, from /root/devdir/php-7.3.4/ext/zip/php_zip.c:36:/usr/local/include/zip.h:59:21: 致命错误:zipconf.h:没有那个文件或目录 #include ^编译中断。make: *** [ext/zip/php_zip.lo] 错误 1解决方案:cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h[root@localhost php-7.3.4]# cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/

测试PHP是否安装成功

Installing PEAR environment: /usr/local/php/lib/php/[PEAR] Archive_Tar - installed: 1.4.5[PEAR] Console_Getopt - installed: 1.4.2[PEAR] Structures_Graph- installed: 1.1.1[PEAR] XML_Util - installed: 1.4.3[PEAR] PEAR - installed: 1.10.9Wrote PEAR system config file at: /usr/local/php/etc/pear.confYou may want to add: /usr/local/php/lib/php to your php.ini include_path/root/devdir/php-7.3.4/build/shtool install -c ext/phar/phar.phar /usr/local/php/binln -s -f phar.phar /usr/local/php/bin/pharInstalling PDO headers: /usr/local/php/include/php/ext/pdo/[root@localhost php-7.3.4]# php -v-bash: php: 未找到命令[root@localhost php-7.3.4]# ll /usr/local/php/bin/ etc/ include/ lib/ php/ sbin/ var/ [root@localhost php-7.3.4]# ll /usr/local/php/bin/ppear pecl phar.phar php-cgi phpdbg peardev phar php php-config phpize [root@localhost php-7.3.4]# vim /etc/profile[root@localhost php-7.3.4]# source /etc/profile[root@localhost php-7.3.4]# php -vPHP 7.3.4 (cli) (built: May 9 2019 17:39:42) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies[root@localhost php-7.3.4]#

转载自:https://my.oschina.net/u/4127346/blog/3047778

1.《php7 centos7系统源码编译安装PHP7.3.5版本》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。

2.《php7 centos7系统源码编译安装PHP7.3.5版本》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。

3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/keji/347633.html