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

行动起来,活在当下

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

目 录CONTENT

文章目录

服务部署 编译PHP8.2

安装部署

设置环境变量

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

创建系统账号

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

安装依赖

dnf install epel-release -y
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

依赖说明

oniguruma
  • oniguruma 是一个正则表达式库,支持多种字符编码和正则表达式语法。PHP 中的 mbstring 扩展(多字节字符串扩展)使用 oniguruma 库来处理正则表达式相关的功能。

  • 如果您打算在 PHP 中使用 mbstring 扩展,并且需要利用它的正则表达式功能,那么您需要安装 oniguruma 库。

oniguruma-devel
  • oniguruma-devel 包含了 oniguruma 库的开发文件,如头文件和静态库,这些文件通常在编译时需要。

  • 如果您计划从源代码编译 PHP,并且要启用 mbstring 扩展,那么安装 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-freetype \
--with-jpeg \
--with-zlib \
--with-curl \
--with-openssl \
--with-mhash \
--with-gettext \
--with-xsl   \
--with-zip \
--with-libxml \
--with-pear \
--disable-rpath \
--enable-mysqlnd  \
--enable-gd \
--enable-fpm \
--enable-ftp \
--enable-xml \
--enable-intl \
--enable-soap \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-pcntl \
--enable-sockets \
--enable-mbregex  \
--enable-mbstring \
--enable-opcache \
--enable-zts \
--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


sudo yum install ImageMagick ImageMagick-devel ImageMagick-perl
# centos 8 安装
pecl install imagick

  - epel-release
      - pcre-devel
      - openssl-devel
      - gcc
      - curl
      - geoip-devel
      - 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
      - libzip
      - libzip-devel
      - sqlite-devel
      # - oniguruma
      # - oniguruma-devel
      - libzip
      - libzip-devel
      - pcre-devel
      - gcc
      - curl
cmd: ./configure --prefix=/usr/local/php-{{version}} --with-config-file-path=/usr/local/php-{{version}}/etc {{parameters}}
chdir: /srv/php-{{version}}
vars:
  parameters: --with-fpm-user={{runner_user}}
      --with-fpm-group={{runner_user}}
      --enable-mysqlnd
      --with-mysqli=mysqlnd
      --with-mysql
      --with-mcrypt
      --enable-gd-native-ttf
      --with-pdo-mysql=mysqlnd
      --with-iconv-dir
      --with-freetype-dir
      --with-jpeg-dir
      --with-png-dir
      --with-zlib
      --with-zlib-dir
      --with-curl
      --with-mcrypt
      --with-gd
      --with-openssl
      --with-mhash
      --with-xmlrpc
      --with-gettext
      --with-libxml-dir
      --with-bz2
      --without-pear
      --enable-fpm
      --enable-ftp
      --enable-xml
      --with-xsl
      --enable-intl
      --enable-zip
      --enable-soap
      --enable-bcmath
      --enable-shmop
      --enable-sysvsem
      --enable-inline-optimization
      --enable-gd-native-ttf
      --enable-pcntl
      --enable-sockets
      --enable-maintainer-zts
      --enable-mbregex
      --enable-mbstring
      --enable-opcache
      --enable-exif	  

参考文档

php安装gd扩展的方法

php_ini not set to php.ini location

0

评论区