Ubuntu系统Apache2多站点支持多个不同版本的PHP版本
# 简介
在当前最新版本 Ubuntu20 系统中,默认的软件源只搭建了最新的 php 版本,如果想要下载多个不同的 php 版本,可以添加 php 的软件源.
# 安装
从 PPA安装软件时,通常会在命令前加上:
sudo apt install software-properties-common
添加软件源:
sudo add-apt-repository ppa:ondrej/php
更新软件列表:
sudo apt update -y
安装php5.6:
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
安装php7.2:
apt install php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache -y
安装后查看状态是否在运行:
sudo systemctl status php5.6-fpm
sudo systemctl status php7.2-fpm
# Apache 多站点文件配置
apache2 安装: sudo apt install apache2 libapache2-mod-fcgid
<VirtualHost *:80>
ServerAdmin php5.6
ServerName www.test56.com
DocumentRoot /var/www/test56
<Directory "/var/www/test56">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
上次更新: 2023/09/19, 09:25:06