CentOS8编译PHP8

编译所需的依赖和配置都整理好了,复制粘贴即用。

都CentOS8了,官方源自带的php还是7.2版本,装个php8好了。

先下载解压并进入php8的源码目录:

wget https://www.php.net/distributions/php-8.0.3.tar.gz
tar xzf php-8.0.3.tar.gz
cd php-8.0.3

如果提示:

-bash: wget: command not found

就是没有安装wget,先安装再执行上面的命令:

yum install wget -y

安装工具包和依赖:

yum install epel-release -y
yum groupinstall "Development tools" -y
yum install dnf-plugins-core
yum config-manager --set-enabled powertools
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 libzip-devel \
            systemtap-sdt-devel libicu-devel systemd-devel -y

编译配置:把能开启的功能都打开:

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

编译并安装:

make && make install

将配置文件复制到php的安装目录:

cp php.ini-production /usr/local/lib/php.ini
注意有两个配置文件,一个是开发版一个是可以投入生产的版本。
安装过程中自动安装apache httpd服务器。

留下评论

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