rocky linux编译安装php 8
侧边栏壁纸
  • 累计撰写 9 篇文章
  • 累计收到 1 条评论

rocky linux编译安装php 8

photonshalo
2025-08-16 / 0 评论 / 18 阅读 / 正在检测是否收录...

编译php之前需要先安装依赖库

安装EPEL仓库

dnf install -y epel-release
dnf clean all
dnf makecache
dnf install -y  wget libxml2-devel sqlite-devel bzip2-devel libcurl-devel libffi-devel libpng-devel libwebp-devel libjpeg-devel oniguruma libzip
dnf install -y gcc make autoconf automake libtool bison gcc  libicu-devel openssl-devel
dnf install -y gcc gcc-c++ make autoconf automake libtool bison re2c  openssl-devel libxml2-devel libpng-devel  libjpeg-devel  libicu-devel curl-devel   sqlite-devel libuuid-devel systemd-devel libxslt-devel readline-devel
​
dnf groupinstall "Development Tools" -y

安装oniguruma-devel和libzip-devel

wget https://dl.rockylinux.org/pub/rocky/9/devel/x86_64/os/Packages/o/oniguruma-devel-6.9.6-1.el9.6.x86_64.rpm
dnf -y install oniguruma-devel-6.9.6-1.el9.6.x86_64.rpm
​
wget https://dl.rockylinux.org/pub/rocky/9/devel/x86_64/os/Packages/l/libzip-devel-1.7.3-8.el9.x86_64.rpm
dnf -y install libzip-devel-1.7.3-8.el9.x86_64.rpm

下载php 8源码

wget https://www.php.net/distributions/php-8.3.22.tar.gz

写编译脚本并编译

chmod +x build.sh && sudo sh build.sh 

编译脚本如下

#!/bin/bash

CURRDIR=`dirname "$0"`
BASEDIR=`cd "$CURRDIR"; pwd`

VERSION=8.3.22
cd $BASEDIR/php-$VERSION

./configure --prefix=/usr/local/php/php-8.3.22 \
    --with-curl \
    --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-zlib \
    --with-bz2 \
    --with-mhash \
    --enable-fpm \
    --enable-bcmath \
    --enable-libxml \
    --enable-gd \
    --enable-mbregex \
    --enable-mbstring \
    --enable-opcache \
    --enable-pcntl \
    --enable-shmop \
    --enable-soap \
    --enable-sockets \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-xml \
    --enable-zip

  make && make install

编译完成后需要到/usr/local/php/php-8.3.22目录下查看bin目录下的php版本,和sbin目录下的php-fpm的版本

2

评论 (0)

取消