Centos7 编译 PHP7.4.26

yum -y install epel-release libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel uuid uuid-devel libuuid-devel gcc bzip2 bzip2-devel gmp-devel  readline-devel libxslt-devel autoconf bison re2c gcc gcc-c++ sqlite-devel oniguruma-devel cmake libtool libarchive libzip libzip-devel

如果是 centos8 系统的话 oniguruma 得自己装 centos8 编译 安装 php7.x 出现 Package requirements (oniguruma) were not met 的处理

cd /opt
wget http://cn2.php.net/distributions/php-7.4.26.tar.gz
tar -zxvf php-7.4.26.tar.gz
cd php-7.4.26

./configure \
--prefix=/opt/php/7.4.26 \
--with-config-file-path=/opt/php/7.4.26/etc \
--with-config-file-scan-dir=/opt/php/7.4.26/etc/conf.d \
--enable-fpm \
--enable-soap \
--with-openssl \
--with-openssl-dir \
--with-zlib \
--enable-gd \
--with-jpeg \
--with-freetype \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-ftp \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-mbstring \
--enable-pdo \
--with-pdo-mysql \
--with-zlib-dir \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-xsl \
--enable-mysqlnd \
--with-mysqli \
--without-pear \
--disable-short-tags \
-enable-gd \
--with-freetype \
--with-jpeg 

PHP7.4 一些变更
CURL:
--with-curl no longer accepts a directory.
Enchant:
--with-enchant no longer accepts a directory.
FPM:
--with-fpm-systemd now uses only pkg-config for libsystem checks. The libsystemd minimum required version is 209.
GD:
--with-gd becomes --enable-gd (whether to enable the extension at all) and --with-external-gd (to opt into using an external libgd, rather than the bundled one).
--with-png-dir has been removed. libpng is required.
--with-zlib-dir has been removed. zlib is required.
--with-freetype-dir becomes --with-freetype
--with-jpeg-dir becomes --with-jpeg
--with-webp-dir becomes --with-webp
--with-xpm-dir becomes --with-xpm
IMAP:
--with-kerberos-systemd no longer accepts a directory.
Intl:
--with-icu-dir has been removed. If --enable-intl is passed, then libicu is always required.
LDAP:
--with-ldap-sasl no longer accepts a directory.
Libxml:
--with-libxml-dir has been removed.
--enable-libxml becomes --with-libxml.
--with-libexpat-dir has been renamed to --with-expat and no longer accepts a directory.
Litespeed:
--with-litespeed becomes --enable-litespeed.
Mbstring:
--with-onig has been removed. Unless --disable-mbregex has been passed, libonig is required.
ODBC:
--with-iodbc no longer accepts a directory.
--with-unixODBC without a directory now uses pkg-config (preferred). Directory is still accepted for old versions without libodbc.pc.
OpenSSL:
--with-openssl no longer accepts a directory.
PCRE:
--with-pcre-regex has been removed. Instead --with-external-pcre is provided to opt into using an external PCRE library, rather than the bundled one.
PDO_SQLite:
--with-pdo-sqlite no longer accepts a directory.
Readline:
--with-libedit no longer accepts a directory.
Sodium:
--with-sodium no longer accepts a directory.
SQLite3:
--with-sqlite3 no longer accepts a directory.
XSL:
--with-xsl no longer accepts a directory.
Zip:
--with-libzip has been removed.
--enable-zip becomes --with-zip.

make && make install

Installing shared extensions:     /opt/php/7.4.26/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /opt/php/7.4.26/bin/
Installing PHP CLI man page:      /opt/php/7.4.26/php/man/man1/
Installing PHP FPM binary:        /opt/php/7.4.26/sbin/
Installing PHP FPM defconfig:     /opt/php/7.4.26/etc/
Installing PHP FPM man page:      /opt/php/7.4.26/php/man/man8/
Installing PHP FPM status page:   /opt/php/7.4.26/php/php/fpm/
Installing phpdbg binary:         /opt/php/7.4.26/bin/
Installing phpdbg man page:       /opt/php/7.4.26/php/man/man1/
Installing PHP CGI binary:        /opt/php/7.4.26/bin/
Installing PHP CGI man page:      /opt/php/7.4.26/php/man/man1/
Installing build environment:     /opt/php/7.4.26/lib/php/build/
Installing header files:          /opt/php/7.4.26/include/php/
Installing helper programs:       /opt/php/7.4.26/bin/
  program: phpize
  program: php-config
Installing man pages:             /opt/php/7.4.26/php/man/man1/
  page: phpize.1
  page: php-config.1
/opt/downfile/php-7.4.26/build/shtool install -c ext/phar/phar.phar /opt/php/7.4.26/bin/phar.phar
ln -s -f phar.phar /opt/php/7.4.26/bin/phar
Installing PDO headers:           /opt/php/7.4.26/include/php/ext/pdo/
cp php.ini-production /opt/php/7.4.26/etc/php.ini
cp sapi/fpm/php-fpm.service  /etc/systemd/system/php7426.service
chmod 755 /etc/systemd/system/php7426.service
systemctl daemon-reload

使用 sock 权限问题的解决方案

新建一个用户及组如 app

useradd app

更改 conf

mv  /opt/php/7.4.26/etc/php-fpm.conf.default  /opt/php/7.4.26/etc/php-fpm.conf
mv /opt/php/7.4.26/etc/php-fpm.d/www.conf.default /opt/php/7.4.26/etc/php-fpm.d/www.conf
vi  /opt/php/7.4.26/etc/php-fpm.d/www.conf

user = app
group =app
listen.owner = app
listen.group = app
未避免冲突,可以改一下端口号
listen = 127.0.0.1:9000 修改为 127.0.0.1:9001

#启动PHP
systemctl start php7426.service
#加入启动项
systemctl enable php7426.service
#查看状态
systemctl status php7426.service

● php7426.service - The PHP FastCGI Process Manager
   Loaded: loaded (/etc/systemd/system/php7426.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-01-20 10:33:09 CST; 2s ago
 Main PID: 181938 (php-fpm)
    Tasks: 3 (limit: 11483)
   Memory: 10.8M
   CGroup: /system.slice/php7426.service
           ├─181938 php-fpm: master process (/opt/php/7.4.26/etc/php-fpm.conf)
           ├─181939 php-fpm: pool www
           └─181940 php-fpm: pool www

如果启动出现 code=exited, status=203/EXEC 的错误,可以尝试关闭 setenforce

# 临时关闭 setenforce
setenforce 0

# 永久关闭 setenforce
vi /etc/selinux/config

SELINUX=enforcing 修改为 SELINUX=disabled

安装新版本的 cmake

wget https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1.tar.gz
tar -zxvf cmake-3.20.1.tar.gz
cd cmake-3.20.1
./bootstrap
gmake
make install
/usr/local/bin/cmake --version
ln -s /usr/local/bin/cmake /usr/bin/

安装新版本的 libzip

wget https://libzip.org/download/libzip-1.7.3.tar.gz
tar -zxvf libzip-1.7.3.tar.gz
cd libzip-1.7.3
mkdir build
cmake ..
make && make install

Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib64/pkgconfig/libzip.pc
-- Installing: /usr/local/include/zipconf.h
-- Installing: /usr/local/lib64/cmake/libzip/libzip-config.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-config-version.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-targets.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-targets-noconfig.cmake
-- Installing: /usr/local/lib64/libzip.so.5.3
-- Installing: /usr/local/lib64/libzip.so.5
-- Installing: /usr/local/lib64/libzip.so
-- Installing: /usr/local/include/zip.h
...... 略
# 编译安装扩展 时可以为 configure 指定环境
export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"

如果执行 cmake .. 提示 cmake: symbol lookup error: cmake: undefined symbol: archive_write_add_filter_zstd
那么还需要安装 libarchive , 如 centos8 yum install libarchive

安装新版本的GD

wget http://www.ijg.org/files/jpegsrc.v9d.tar.gz
tar zxvf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
make && make install

安装新版的libgd

 wget https://github.com/libgd/libgd/releases/download/gd-2.3.2/libgd-2.3.2.tar.gz
tar xf libgd-2.3.2.tar.gz 
cd libgd-2.3.2
./configure --bindir=/usr/sbin/ \
            --sbindir=/usr/sbin/ \
            --libexecdir=/usr/libexec \
            --sysconfdir=/etc/ \
            --localstatedir=/var \
            --libdir=/usr/lib64/  \
            --includedir=/usr/include/ \
            --datarootdir=/usr/share \
            --infodir=/usr/share/info \
            --localedir=/usr/share/locale \
            --mandir=/usr/share/man/ \
            --docdir=/usr/share/doc/libgd


make && make install

 /usr/bin/mkdir -p '/usr/sbin'
  /bin/sh ../libtool   --mode=install /usr/bin/install -c gdcmpgif gdtopng pngtogd webpng gdparttopng gd2topng pngtogd2 annotate gd2copypal gd2togif giftogd2 '/usr/sbin'
libtool: install: /usr/bin/install -c .libs/gdcmpgif /usr/sbin/gdcmpgif
libtool: install: /usr/bin/install -c .libs/gdtopng /usr/sbin/gdtopng
libtool: install: /usr/bin/install -c .libs/pngtogd /usr/sbin/pngtogd
libtool: install: /usr/bin/install -c .libs/webpng /usr/sbin/webpng
libtool: install: /usr/bin/install -c .libs/gdparttopng /usr/sbin/gdparttopng
libtool: install: /usr/bin/install -c .libs/gd2topng /usr/sbin/gd2topng
libtool: install: /usr/bin/install -c .libs/pngtogd2 /usr/sbin/pngtogd2
libtool: install: /usr/bin/install -c .libs/annotate /usr/sbin/annotate
libtool: install: /usr/bin/install -c .libs/gd2copypal /usr/sbin/gd2copypal
libtool: install: /usr/bin/install -c .libs/gd2togif /usr/sbin/gd2togif
libtool: install: /usr/bin/install -c .libs/giftogd2 /usr/sbin/giftogd2
 /usr/bin/mkdir -p '/usr/sbin'
 /usr/bin/install -c bdftogd '/usr/sbin'
 /usr/bin/mkdir -p '/usr/include'
 /usr/bin/install -c -m 644 gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h entities.h gd_color_map.h gd_errors.h gdpp.h '/usr/include'
make[2]: Leaving directory `/opt/downfile/libgd-2.3.2/src'
make[1]: Leaving directory `/opt/downfile/libgd-2.3.2/src'
Making install in config
make[1]: Entering directory `/opt/downfile/libgd-2.3.2/config'
make[2]: Entering directory `/opt/downfile/libgd-2.3.2/config'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/lib64/pkgconfig'
 /usr/bin/install -c -m 644 gdlib.pc '/usr/lib64/pkgconfig'
make[2]: Leaving directory `/opt/downfile/libgd-2.3.2/config'
make[1]: Leaving directory `/opt/downfile/libgd-2.3.2/config'
Making install in tests
make[1]: Entering directory `/opt/downfile/libgd-2.3.2/tests'
make[2]: Entering directory `/opt/downfile/libgd-2.3.2/tests'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/downfile/libgd-2.3.2/tests'
make[1]: Leaving directory `/opt/downfile/libgd-2.3.2/tests'
make[1]: Entering directory `/opt/downfile/libgd-2.3.2'
make[2]: Entering directory `/opt/downfile/libgd-2.3.2'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/downfile/libgd-2.3.2'
make[1]: Leaving directory `/opt/downfile/libgd-2.3.2'

安装新版 Mariadb

cd /etc/yum.repos.d/
vi /etc/yum.repos.d/MariaDB.repo

// 写入
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.5/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

//安装
yum -y install mariadb mariadb-server

新版的 nginx,可以到
 http://nginx.org/packages/centos/7/x86_64/RPMS/
 安装


报错:
···
configure: error: Package requirements (libpcre2-8 >= 10.30) were not met:
···
wget https://ftp.pcre.org/pub/pcre/pcre2-10.34.tar.bz2
tar xjvf pcre2-10.34.tar.bz2
./configure --prefix=/usr/local/pcre2
--enable-pcre2-16
--enable-pcre2-32
--enable-jit
--enable-jit-sealloc

make && make install

export PKG_CONFIG_PATH=/usr/local/pcre2/lib/pkgconfig/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,012评论 4 359
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,589评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 106,819评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,652评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 51,954评论 3 285
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,381评论 1 210
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,687评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,404评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,082评论 1 238
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,355评论 2 241
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,880评论 1 255
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,249评论 2 250
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,864评论 3 232
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,007评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,760评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,394评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,281评论 2 259