江明涛的博客
CentOS 7 编译安装PHP8.1.1
CentOS 7 编译安装PHP8.1.1

CentOS 7 编译安装PHP8.1.1

下载并解压 php 8.1.1

官网下载地址:https://www.php.net/downloads.php

#下载
wget https://www.php.net/distributions/php-8.1.1.tar.gz
#解压
tar -xvf php-8.1.1.tar.gz

安装依赖

yum install -y oniguruma-devel openssl-devel gcc gcc-c++ wget make libxml2 libxml2-devel openssl \
openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel  \
bison autoconf sqlite-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libxslt-devel  \ 
libxslt libzip-devel libtidy-devel libtidy gmp gmp-devel libmcrypt libmcrypt-devel readline \
readline-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses gdbm-devel db4-devel \
libXpm-devel libX11-devel gd-devel expat-devel xmlrpc-c xmlrpc-c-devel libmemcached-devel \
libsqlite3x-devel 

编译安装

进入解压后的目录

cd php-8.1.1/

编译

./configure \
--prefix=/usr/local/php8 \
--with-config-file-path=/usr/local/php8/etc \
--enable-fpm \
--enable-mysqlnd \
--with-fpm-user=www \
--with-fpm-group=www \
--with-curl \
--enable-gd \
--with-tidy \
--with-gettext \
--enable-intl \
--with-kerberos \
--with-libdir=lib64 \
--with-mysqli \
--enable-ftp \
--with-openssl \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--disable-fileinfo \
--with-xsl \
--with-zlib \
--with-bz2 \
--with-mhash \
--enable-bcmath \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-xml \
--enable-calendar \
--enable-exif 

出现以下信息表示编译成功


+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

安装

make && make install

配置环境变量

修改/etc/profile 配置文件

vim /etc/profile

#将以下代码复制到文件的最下面
PATH=$PATH:/usr/local/php8/bin
export PATH

刷新环境变量

source /etc/profile

创建用户和用户组

创建用户组

groupadd www

创建用户

useradd -g www -s /sbin/nologin www

启动php

service php-fpm start

上次更新时间 20 3 月, 2023 at 09:30 上午