Centos7 编译 PHP7.4.26

Linux文章/教程评论651阅读模式
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文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

安装新版本的 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文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

安装新版的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/
安装文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

报错:
···
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文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

make && make install文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

export PKG_CONFIG_PATH=/usr/local/pcre2/lib/pkgconfig/文章源自爱尚资源教程网-https://www.23jcw.net/1175.html

文章源自爱尚资源教程网-https://www.23jcw.net/1175.html文章源自爱尚资源教程网-https://www.23jcw.net/1175.html
相关文章
版权声明:文章图片资源来源于网络,如有侵权,请留言删除!!!
  • 温馨提示:如遇到资源下载不了,或者文章没有解决你的问题的,可以联系我们帮你处理!!!
  • 转载请务必保留本文链接:https://www.23jcw.net/1175.html

发表评论