php7安装

技术 置顶 精帖
0 816
peng49
peng49 2022-03-08 09:57:28
 

yum源安装7.3

安装 Remi 存储库

  1. sudo yum -y install epel-release yum-utils
  2. sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

启用Remi 存储库中的php7.3源

  1. sudo yum-config-manager --enable remi-php73

安装 PHP 7.3 和一些最常见的 PHP 模块

  1. sudo yum -y install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd php-mbstring php-dom php-fpm

验证是否安装成功

  1. php -v
  1. PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:28) ( NTS )
  2. Copyright (c) 1997-2018 The PHP Group
  3. Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
  4. with Zend OPcache v7.3.33, Copyright (c) 1999-2018, by Zend Technologies

安装成功

编译安装7.4

安装依赖包

  1. yum install -y gcc make libxml2 libxml2-devel openssl openssl-devel sqlite-devel libcurl libcurl-devel oniguruma oniguruma-devel

下载php安装包

  1. curl -L https://www.php.net/distributions/php-7.4.28.tar.gz -o php-7.4.28.tar.gz

解压

  1. tar -zxvf php-7.4.28.tar.gz
  2. cd php-7.4.28

编译

  1. ./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74 --enable-mbstring --with-openssl --with-my
  2. sqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-cli --with-curl

安装

  1. make && make install

验证安装

  1. /usr/local/php74/bin/php -v
  1. PHP 7.4.28 (cli) (built: Mar 8 2022 02:34:31) ( NTS )
  2. Copyright (c) The PHP Group
  3. Zend Engine v3.4.0, Copyright (c) Zend Technologies

安装成功

配置php.ini

  1. cp php.ini-development /usr/local/php74/php.ini

检查配置文件

  1. /usr/local/php74/bin/php --ini
  1. Configuration File (php.ini) Path: /usr/local/php74
  2. Loaded Configuration File: /usr/local/php74/php.ini
  3. Scan for additional .ini files in: (none)
  4. Additional .ini files parsed: (none)

php.ini已生效

参考链接
Install PHP 7 on CentOS 7
Debian GNU/Linux 安装说明
CentOS 7 编译安装 PHP 7.4 提示 No package oniguruma found

回帖
登录
忘记密码?