centos7安装php7.2环境
时间: 2024-12-15 21:19:51 浏览: 16
在CentOS 7上安装PHP 7.2需要几个步骤。以下是详细的安装过程:
1. **更新系统**:
```
sudo yum update -y
```
2. **安装依赖包**:
```
sudo yum install -y epel-release # 如果还没有安装EPEL仓库,需要先安装
sudo yum install -y wget
```
3. **下载并解压PHP源码**:
```
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/php72u-php-cli.rpm
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/php72u-php-fpm.rpm
```
4. **安装PHP CLI** (命令行工具):
```
sudo rpm -ivh php72u-php-cli.rpm
```
5. **安装PHP FPM (FastCGI进程管理器)**:
```
sudo rpm -ivh php72u-php-fpm.rpm
```
6. **启动和启用FPM服务**:
```
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
```
7. **检查PHP是否安装成功**:
打开终端,运行 `php -v` 来查看PHP版本。
阅读全文