CentOS7编译PHP8

系统自带源的PHP版本太低,装个WordPress都不行。编译开启的功能和依赖站长都整理好了。
CentOS7官方源的php是7.2版本的,不够WordPress的最低要求。
不多说,直接给干到最新版。

先卸载从官方源下载的PHP以及依赖:

yum remove php -y
yum autoremove

下载源码包并解压进入源码目录:

yum install wget -y
wget https://www.php.net/distributions/php-8.0.12.tar.gz
tar xzf php-8.0.12.tar.gz
cd php-8.0.12

下载喜闻乐见的工具包和依赖们:

yum install epel-release -y
yum groupinstall "Development tools" -y
yum install libxml2-devel sqlite-devel oniguruma-devel httpd-devel \
            mysql-devel enchant-devel libffi-devel libwebp-devel \
            libXpm-devel libiodbc-devel libsodium-devel libxslt-devel \
            libcurl-devel libpng-devel libjpeg-devel freetype-devel \
            systemd-devel libacl-devel valgrind-devel libicu-devel \
            libedit-devel -y

注意,开启zip支持需要安装libzip

配置编译选项,能开启的功能都开启:

./configure --with-apxs2=/usr/bin/apxs \
            --with-mysqli=/usr/bin/mysql_config \
            --with-mysql-sock=/var/lib/mysql/mysql.sock \
            --with-openssl \
            --with-kerberos \
            --with-zlib \
            --with-curl \
            --with-enchant \
            --with-ffi \
            --with-webp \
            --with-jpeg \
            --with-xpm \
            --with-freetype \
            --with-zip \
            --with-pcre-jit \
            --with-mhash \
            --with-imap-ssl \
            --with-iodbc \
            --with-sodium \
            --with-xsl \
            --with-valgrind \
            --with-imap-ssl \
            --with-ldap-sasl \
            --with-unixODBC \
            --with-libedit \
            --enable-intl \
            --enable-exif \
            --enable-soap \
            --enable-gd \
            --enable-gd-jis-conv \
            --enable-zts \
            --enable-mbstring \
            --enable-sockets \
            --enable-sigchild \
            --enable-bcmath \
            --enable-calendar \
            --enable-dba \
            --enable-ftp \
            --enable-sysvmsg \
            --enable-sysvsem \
            --enable-sysvshm \
            --enable-fpm \
            --enable-shmop \
            --with-fpm-systemd \
            --with-fpm-acl

编译并安装:

make && make install

复制PHP配置文件到规定的目录,完成:

cp php.ini-production /usr/local/lib/php.ini

注意,以上命令默认安装Apache httpd服务器!

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注