7.3.x 版本安装
安装所需依赖
由于需要 libzip 高版本,所以需要 cmake,首先编译安装 cmake,然后编译安装 libzip。
cmake 官网:https://cmake.org/download/
libzip 官网:https://libzip.org/download/
然后安装相关依赖
yum install -y systemd-devel \
systemtap-sdt-devel \
libxml2-devel \
openssl-devel \
bzip2-devel \
curl-devel \
libwebp-devel \
libjpeg-devel \
libpng-devel \
freetype-devel \
gmp-devel \
libicu-devel \
glibc-headers gcc-c++
如果遇到:configure: error: off_t undefined; check your library configuration
添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
更新配置
ldconfig -v
编译 PHP
编译完成后,在 sapi/fpm
中有个 init.d.php-fpm 安装完成后需要复制到 init.d 文件中。
./configure --prefix=/usr/local/php-7.3 \
--exec-prefix=/usr/local/php-7.3 \
--with-config-file-path=/usr/local/php-7.3/etc \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--with-openssl \
--with-zlib \
--with-bz2 \
--with-curl \
--with-gd \
--with-freetype-dir \
--enable-exif \
--with-webp-dir \
--with-jpeg-dir \
--with-png-dir \
-with-gettext \
--with-gmp \
--with-mhash \
--with-iconv \
--enable-intl \
--with-mysqli=mysqlnd \
--with-mysql-sock=/var/mariadb/mysql.sock \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-zip \
--with-libzip \
--enable-mysqlnd \
--with-openssl \
--with-fpm-systemd \
--enable-opcache \
--enable-shmop \
--enable-xml \
--enable-dtrace \
--disable-rpath \
--with-pcre-regex \
--with-xmlrpc \
--with-imap-ssl \
--enable-pcntl \
--enable-mbstring
最新 7.4 版本编译安装
依赖环境 oniguruma-devel
环境变量设置
export LIBZIP_CFLAGS=/usr/local/lib64
export LIBZIP_LIBS=/usr/local/lib64
编译选项
./configure --prefix=/usr/local/php-7.4.0 \
--with-config-file-path=/usr/local/php-7.4.0/etc \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--with-openssl \
--with-zlib \
--with-curl \
--enable-gd \
--with-webp \
--with-jpeg \
--with-freetype \
--enable-gd-jis-conv \
--enable-exif \
-with-gettext \
--with-gmp \
--with-mhash \
--with-iconv \
--enable-intl \
--with-mysqli=mysqlnd \
--with-mysql-sock=/var/mariadb/mysql.sock \
--with-pdo-mysql=mysqlnd \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-mysqlnd \
--with-openssl \
--with-fpm-systemd \
--enable-opcache \
--enable-shmop \
--enable-xml \
--enable-dtrace \
--disable-rpath \
--with-pcre-jit \
--without-sqlite3 \
--without-pdo-sqlite \
--with-xmlrpc \
--with-imap-ssl \
--enable-pcntl \
--enable-mbstring