RedHat7.6 安装php7.4

RedHat7.6 安装php7.4
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
tar -zxf libsodium-1.0.18-stable.tar.gz
cd libsodium-stable
./configure --prefix=/usr
make && make check
sudo make install
sudo ldconfig

备用下载地址:https://down.24kplus.com/linux/libsodium-1.0.18-stable.tar.gz

下载编译安装sodium

yum install autoconf

核对导入/usr/lib/pkgconfig路径

echo  $PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
echo $PKG_CONFIG_PATH

安装依赖

yum 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 zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel

下载PHP

wget https://www.php.net/distributions/php-7.4.27.tar.gz

解压

tar -zxvf php-7.4.27.tar.gz
cd php-7.4.27.tar.gz

编译安装(如果有要开启其他的php module, 要在下面的参数中加上)

./configure \
--prefix=/usr/local/php74 \
--with-config-file-path=/usr/local/php74/etc \
--enable-fpm \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype \
--with-jpeg \
--with-zlib \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--enable-opcache \
--with-sodium \
--with-webp

安装

make
make install

编译时可能会出现一些错误 configure error:

1. configure: error: Please reinstall the BZip2 distribution
    解决:yum install bzip2 bzip2-devel -y

2. configure: error: Package requirements (libcurl >= 7.15.5) were not met:No package 'libcurl' found
    解决:yum install libcurl libcurl-devel -y

3.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
    解决:yum install libxslt libxslt-devel -y

4.configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
    解决:yum install sqlite-devel -y

5.configure: error: GNU MP Library version 4.2 or greater required.
    解决:yum install gmp-devel -y   

6.configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found
    解决:yum install oniguruma-devel -y

7.configure: error: Please reinstall readline - I cannot find readline.h
    解决:yum install readline-devel -y

8.configure: error: Package requirements (libpcre2-8 >= 10.30) were not met: No package 'libpcre2-8' found
    解决:https://www.jianshu.com/p/89646111a1ce

9.configure: error: DBA: Could not find necessary header file(s).
     解决:yum install gdbm-devel -y
10.configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:No package 'libzip' found
    解决:https://www.jianshu.com/p/6cbd25addc29
11.configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met: No package 'libxml-2.0' found
    解决:yum install libxml2-devel -y
12.configure: error: Package requirements (libpng) were not met: No package 'libpng' found
    解决:yum install libpng-devel -y
13.configure: error: Package requirements (libjpeg) were not met:No package 'libjpeg' found
    解决:yum install libjpeg-devel -y
14.configure: error: Package requirements (freetype2) were not met:No package 'freetype2' found
    解决:yum install freetype-devel -y
15.configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:
    No package 'icu-uc' found
    No package 'icu-io' found
    No package 'icu-i18n' found
    解决:yum install libicu-devel -y

删除临时文件

make clean
make distclean

配置环境变量:
可以在 /etc/profile文件末尾添加php环境变量

PATH=$PATH:/usr/local/php71/bin
export PATH

#保存后刷新环境变量:
source /etc/profile

#查看环境变量:
echo $PATH

#查看php版本
php -v

配置PHP

cp php.ini-production /usr/local/php/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

#复制启动脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

开机启动

systemctl enable php-fpm
systemctl start php-fpm

php-fpm的启动、停止和重启:

#启动
service php-fpm start

#停止
service php-fpm stop

#重启
service php-fpm restart

参考地址1;

CentOS-7 编译安装php-7.4 - cchenppp - 博客园
1、环境准备 虚拟机:centos 7 ip:192.168.137.128 php-7.4.8.tar.gz 2、开始安装 添加php用户,用于运行php-fpm进程 useradd php -s

参考地址2;

linux centos7 安装php7.4 实测 遇到的坑_舰长115的博客-CSDN博客
目录1、下载tar包 下载地址https://www.php.net/downloads2.安装依赖3.解压tar xvf php-7.4.22.tar.gz出现 Thank you for using PHP 说明编译成功4.安装 make && make install添加环境变量1、下载tar包 下载地址https://www.php.net/downloads2.安装依赖yum -y install gcc gcc-c++ libx...

关于参考地址2中 缺少 oniguruma 和 oniguruma-devel 的问题,正常情况下,只需要运行要一下命令安装即可;

yum -y install  oniguruma  oniguruma-devel

但是1,我的机器是内网环境 2. 我的机器是redhat系统,arm64架构的机器 网上arm64架构的yum源在没有办法通过一下命令自动安装,就算临时开了外网,通过以下命令安装arm64架构的yum源,也会出现各种各样的问题。

rpm -Uvh https://*************.noarch.rpm

所以我最终在这里搜索并下载自己需要的rpm安装包;通过yum install 安装下载到本地的包。(ps; 遇到相关缺少的依赖,在此网站上搜索并安装即可)

https://pkgs.org/

相关文章