一、编译安装php 7.4.x
参考CentOS 8.0.1905编译安装Nginx1.16.1+MySQL8.0.18+PHP7.3.10
1、安装编译工具及库文件(使用yum命令安装)
yum install apr* autoconf automake bison bzip2 bzip2* cpp curl curl-devel fontconfig fontconfig-devel freetype-devel gcc gcc-c++ gd gd-devel gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff libtiff* make openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet wget zlib-devel ncurses-devel libtirpc-devel gtk* ntpstat bison* sqlite-devel oniguruma libzip-devel
2、编译php 7.4.x 需要安装oniguruma
cd /usr/local/src
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
或者
wget http://down.24kplus.com/linux/oniguruma/oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4
./autogen.sh
./configure --prefix=/usr
make
make install
3、编译php 7.4.x 需要安装libzip
cd /usr/local/src
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
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#拷贝文件,否则安装php可能会报错 /usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or dire
4、php 7.4.x编译参数
export LD_LIBRARY_PATH=/usr/local/libgd/lib #设置libgd库环境变量
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" #设置libzip环境变量
./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-xpm=/usr/lib64 --with-zlib-dir=/usr/local/zlib --with-iconv --with-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --with-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype --enable-mysqlnd --enable-pdo
make #编译
make install #安装
./configure --help #可以查看编译参数的写法
5、编译php报错
5.1 没有设置libzip环境变量export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
No package 'libzip' found
checking for libzip >= 0.11... no
configure: error: Package requirements (libzip >= 0.11) were not met:
No package 'libzip' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
5.2缺少sqlite3库 yum install sqlite-devel
error: Package requirements (sqlite3 > 3.7.4) were not met
error: Package requirements (sqlite3 > 3.7.4) were not met
No package 'sqlite3' found
5.3缺少oniguruma 编译安装oniguruma
error: Package requirements (oniguruma) were not met
error: Package requirements (oniguruma) were not met
No package 'oniguruma' found
二、编译安装php 5.6.x
1、安装低版本的openssl
CentOS 8.x默认的openssl版本太高,与php 5.6.x不兼容,需要降低openssl版本才能编译成功
which openssl #查询openssl目录,如/usr/include/openssl
openssl version #查看openssl版本
cd /usr/local/src
mkdir /usr/local/openssl101e
tar zxvf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config --prefix=/usr/local/openssl101e
make
make install
如果安装报错:
cms.pod around line 457: Expected text after =item, not a number
cms.pod around line 461: Expected text after =item, not a number
cms.pod around line 465: Expected text after =item, not a number
cms.pod around line 470: Expected text after =item, not a number
cms.pod around line 474: Expected text after =item, not a number
POD document had syntax errors at /usr/bin/pod2man line 69.
make: *** [install_docs] Error 1
rm -f /usr/bin/pod2man #执行本行代码,再重新编译安装
export PATH=/usr/local/openssl101e/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openssl101e/lib
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L/usr/local/openssl101e/lib -Wl,-rpath,/usr/local/openssl101e/lib"
2、php 5.6.x编译参数
./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/lib64 --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl-dir=/usr/local/openssl101e --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype --enable-mysqlnd
#注意--with-openssl-dir=/usr/local/openssl101e 是我们安装的openssl低版本目录
二、编译安装php 5.3.x
CentOS 8.x默认的openssl版本太高,与php 5.3.x不兼容,需要降低openssl版本才能编译成功
php 5.3.x 需要低版本的gd库gd-2.0.35.tar.gz
gd-2.0.35库编译参数
./configure --prefix=/usr/local/gd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/lib64 --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx
php 5.3.x编译参数
./configure --prefix=/usr/local/php53 --with-config-file-path=/usr/local/php53/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-freetype-dir=/usr/lib --with-iconv --with-zlib-dir=/usr/local/zlib --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl-dir=/usr/local/openssl101e --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype --with-mysqli=shared --enable-mysqlnd
注意:--with-openssl-dir=/usr/local/openssl101e 是我们安装的openssl低版本目录
CentOS 8.x下编译安装php 5.5 php 5.4也和php 5.6一样,需要降低openssl版本才能编译成功。
至此,CentOS 8.x下编译php 7.4、php5.6、php5.3多版本报错处理教程完成。
XIDC作为一家专业的服务器提供商,我们自豪地为您提供香港、美国、日本、韩国、新加坡和台湾等地的服务器接入服务。这些服务器已经成功接入了CN2线路,确保您能够享受到稳定高速的网络连接。
为了满足不同行业客户的需求,我们提供了多样化的配置选择。无论您是个人用户还是企业客户,我们都能为您提供最适合的解决方案。我们的服务器配置涵盖了各种需求,从个人博客到大型企业应用,都能得到满足。
除了优质的服务器接入服务,我们还致力于提供优质的售后服务。我们拥有一支专业的技术团队,他们将全力保障您的服务器稳定运行和数据安全。无论是系统故障还是网络问题,我们都将及时响应并提供解决方案。
为了让您更加放心,我们还提供真机测试服务。如果您对我们的服务器不满意,我们将不收取任何费用。我们相信,只有您满意才是我们最大的成功。
欢迎您访问我们的官网: https://www.xidc.xyz ,了解更多关于我们服务器的信息。无论您是寻找稳定高速的网络连接,还是需要专业的技术支持,XIDC都将是您的最佳选择。让我们携手共创美好未来!申请测试TG: @AmmKiss