服务器编译安装PHP7.4

1、安装基础组件,为后期安装准备

yum install autoconf cmake libxml2-devel openssl-devel sqlite-devel curl-devel libjpeg libjpeg-devel libpng-devel libzip-devel libwebp-devel gmp-devel dnf gcc libicu-dev gcc-c++ libtool autotools-dev automake m4 perl

dnf -y install freetype-devel

安装oniguruma

wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz
tar -zxvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
#autoreconf -ivf
./autogen.sh  #./configure  --prefix=/usr --libdir=/lib64   #
make && make install
cd ../

安装libsodium

wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
tar -zxf libsodium-1.0.18-stable.tar.gz
cd libsodium-stable
./configure 
make && make install
 
方法一:临时生效,重新登录即失效
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
方法二:永久生成
vim /etc/profile
在profile文件加上
export  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
然后执行
source /etc/profile

安装PHP

wget https://www.php.net/distributions/php-7.4.22.tar.gz
tar zxvf php-7.4.22.tar.gz 或本地 tar -jxvf php-7.4.22.tar.gz
cd php-7.4.15/
./buildconf --force

# gmp 使用 –with-gmp 不使用  –enable-gmp

./configure '--prefix=/data/server/php74' '--with-config-file-path=/data/server/php74/etc' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype' '--with-jpeg' '--with-zlib' '--enable-xml' '--enable-gmp'  '--enable-zip' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--enable-intl' '--enable-ftp' '--enable-gd' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-soap' '--with-gettext' '--enable-fileinfo' '--enable-opcache' '--with-sodium=/usr/local' '--with-webp'

make && make install

#mkdir /data/server/php74/etc

cp php.ini-development /data/server/php74/etc/php.ini

# 使用cgi 需要修改 php.ini 去掉下面的注释 1 改为 0

cgi.force_redirect = 0

安装cmake

wget https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1.tar.gz

tar -zxvf cmake-3.28.1.tar.gz

cd cmake-3.28.1

./bootstrap  or ./configure

make && make -install

4、安装 libzip

yum remove libzip -y

(1)、下载安装或直接使用本地包

wget https://nih.at/libzip/libzip-1.10.0.tar.gz 

tar -zxvf libzip-1.10.0.tar.gz

cd libzip-1.10.0

mkdir build

cd build

cmake ..

make && make install

5、安装 zip

(1)、下载安装或直接使用本地包

wget http://pecl.php.net/get/zip-1.21.1.tgz

tar zxfv zip-1.21.1.tgz

cd zip-1.21.1

/data/server/php74/bin/phpize #/usr/bin/phpize

# 出现:

Configuring for:

PHP Api Version:         20190902

Zend Module Api No:      20190902

Zend Extension Api No:   320190902 

./configure  --with-php-config=/data/server/php74/bin/php-config

#对应版本的php目录

#cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

make && make install

#使用 find / -name php.ini 查找配置文件地方

cd /data/server/php74/etc/

#在php.ini里写入

echo extension = zip.so >> php.ini

使用 php -m 检查zip扩展是否安装成功,如果不成功执行 ldconfig /usr/local/lib 和 ldconfig /usr/local/lib64 后,再次通过 php -m 查看

原创文章,作者:admin,如若转载,请注明出处:https://ntib.cn/193.html

(1)
adminadmin
上一篇 2023年11月18日 下午10:56
下一篇 2023年11月18日 下午10:58

相关推荐

发表回复

登录后才能评论
WeChat