因为公司的新的业务需要安装 PHP7 以上的版本,但是如果自己直接使用源码安装的话,可能会有一些依赖忘记安装,或者版本不兼容的问题。而且,使用 百度 搜索出来的又千篇一律抄来抄去根本不具有什么参考价值。
所以,我想到了使用别人写好的shell来安装。经过别人的推荐我知道了 lamp.sh
lamp.sh 是一款使用 Linux Shell 编写的可以在多种系统上运行的 LAMP(Linux + Apache + MySQL + PHP) 安装包。
他有非常多的优点,但有一点是它只允许一种版本的 PHP 在系统上。这个与我的需求有些许的不同。如果直接用它会直接删除我原来的 PHP 版本。于是,我的它源码进行了一些改动,使他只下载新的 PHP 而不删除我原来的版本。
使用方法:
下载 lamp
1
git clone https://github.com/hetaoov/lamp.git
安装
如果你的系统是Amazon Linux/CentOS/Fedora1
2
3
4
5
6yum -y install wget screen git
git clone https://github.com/teddysun/lamp.git
cd lamp
chmod 755 *.sh
screen -S lamp
./lamp --option_php 1|2|3|4|5|6如果你的系统是: Debian/Ubuntu:
1
2
3
4
5
6yum -y install wget screen git
git clone https://github.com/teddysun/lamp.git
cd lamp
chmod 755 *.sh
screen -S lamp
./lamp --option_php 1|2|3|4|5|6
上面 1-5对应的 PHP 版本依次为 PHP5.6,PHP7.0,PHP7.1,PHP7.2,PHP7.3;6 为不安装
- 安装完的目录
安装完成后的默认目录在 /usr/local/php@version 目录下
例如:安装的是7.1版本 则对应的目录为 /usr/local/php@71