# DirectAdmin编译安装多个PHP版本

> 来源：梦飞idc云平台 | 原文：https://www.mfisp.com/22547.html | 发布：2023-07-31 | 更新：2023-07-31 | 分类：运维技术

今天公司的香港网站服务器遇到个问题，两个网站用的程序使用同一个php版本，导致其中一个网站报错。

 

只好去新加一个php版本，让两个网站用不同版本的PHP，因为服务器装的是DirectAdmin面板，所以需要编译安装PHP。

 

下面讲讲具体如何操作。

 

DirectAdmin目前支持最多4版本的PHP同时安装及使用，安装命令如下：

 

## 1、进入安装目录

 

```
#directadmin安装多个版本PHP
cd /usr/local/directadmin/custombuild
./build update
```

 

## 2-1、执行操作命令

 

```
./build set php1_release=5.6
./build set php1_mode=php-fpm
./build set php2_release=7.4
./build set php2_mode=php-fpm
./build set php3_release=7.3
./build set php3_mode=php-fpm
./build set php4_release=8.0
./build set php4_mode=php-fpm
```

 

执行以上命令将会把这些命令写入 options.conf 文件中，并且是写在配置文件最后面的。

 

执行了以上步骤可以跳过2-2。

 

## 2-2、可以直接选择写入命令

 

```
#或者直接编辑
vi options.conf
php1_release=5.6
php1_mode=php-fpm
php2_release=7.4
php2_mode=php-fpm
php3_release=7.3
php3_mode=php-fpm
php4_release=8.0
php4_mode=php-fpm
```

 

## 3、开始编译安装php

 

```
./build php n
./build rewrite_confs
```

 

开始编译php时，会通过 php.net将需要的php版本下载到目录 /usr/local/directadmin/custombuild/cache 中，下载过程中可能出现网络波动导致下载失败，可以重复尝试。

 

## 4-1、常见错误 一

 

```
mod_ruid2 is not supported anymore, please set mod_ruid2=no in CustomBuild 'options.conf'.
```

 

这个错误需要进入 options.conf配置文件中修改 mod_ruid2 = no

 

## 4-2、常见错误 二

 

```
php3_release has been set twice in the options.conf.  This will cause problems. Edit it to remove one of them.
```

 

这个错误是上面2-1和2-2重复执行了，需要打开options.conf配置文件将重复项删除。

 

## 4-3、常见错误 三

 

```
%curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
```

 

这个错误是在编译时，连接php.net下载php版本文件时网络波动造成的连接重置，可以尝试重复执行编译命令。

---
本页由 梦飞idc云平台（https://www.mfisp.com）提供。站点导航见 https://www.mfisp.com/llms.txt
