侧边栏壁纸
博主头像
cn2linux博主等级

行动起来,活在当下

  • 累计撰写 128 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

服务部署 编译PHP7.4

设置环境变量

export USER=www
export PHP_VERSION=7.4.33
export CPUS=$(grep 'cores' /proc/cpuinfo |wc -l)

创建系统账号

id ${USER}||useradd ${USER}  -M -s /usr/bin/false

安装依赖

dnf install -y \
libxml2 libxml2-devel openssl openssl-devel \
bzip2 bzip2-devel libcurl libcurl-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \
gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel \
libxslt libxslt-devel gcc-c++ libicu-devel sqlite-devel libzip-devel 
dnf -y --enablerepo=powertools install oniguruma-devel

下源码包并解压

wget https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz
tar xf php-${PHP_VERSION}.tar.gz
cd php-${PHP_VERSION}/

编译PHP服务

./configure \
--prefix=/usr/local/php-${PHP_VERSION}  \
--with-config-file-path=/usr/local/php-${PHP_VERSION}/etc  \
--with-fpm-user=${USER} \
--with-fpm-group=${USER} \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype \
--with-jpeg \
--with-zlib \
--with-curl \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-gettext \
--with-xsl   \
--with-zip \
--with-libxml \
--disable-rpath \
--enable-mysqlnd  \
--enable-gd \
--with-pear \
--enable-fpm \
--enable-ftp \
--enable-xml \
--enable-intl \
--enable-soap \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-pcntl \
--enable-sockets \
--enable-maintainer-zts \
--enable-mbregex  \
--enable-mbstring \
--enable-opcache \
--enable-exif
make -j${CPUS} && make install

添加软连接

ln -s /usr/local/php-${PHP_VERSION} /usr/local/php

拷贝配置文件

cd sapi/fpm
cp init.d.php-fpm /etc/init.d/php-fpm
chmod 700 /etc/init.d/php-fpm
cp php-fpm.conf /usr/local/php-${PHP_VERSION}/etc/php-fpm.conf
cd /usr/local/php-${PHP_VERSION}/etc/php-fpm.d/
cp www.conf.default www.conf
/etc/init.d/php-fpm start

配置PHP环境变量

cat > /etc/profile.d/PHP-BIN.sh <<EOF
export PHP_BIN=/usr/local/php/bin
export PATH=\${PATH}:\${PHP_BIN}
EOF

source /etc/profile.d/PHP-BIN.sh

清除环境变量

unset USER PHP_VERSION CPUS

0

评论区