同一服务器下使用多版本PHP+Composer

多个项目同时需要使用Composer,但是PHP版本不一样.

多个PHP

  • php7
1
D:\app\phpStudy\PHPTutorial\php\php-7.2.1-nts

将这个目录下的php.exe复制修改成php7.exe,删除php.exe即可.

1
2
3
4
$ php7 -v
PHP 7.2.1 (cli) (built: Jan 4 2018 04:28:54) ( NTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
  • php5
1
D:\app\phpStudy\PHPTutorial\php\php-5.5.38
1
2
3
4
$ php -v
PHP 5.5.38 (cli) (built: Jul 20 2016 11:16:06)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

多个PHP的Composer配置

    1. 直接安装的对应一个全局的Composer
    1. 配置一个需求版本的Composer

例如: 我们需要安装的对应php7.1的composer

  • 下载composer,https://getcomposer.org/download/,将下载的composer.phar移动到~/composer7目录下
  • 配置composer7
1
2
3
vim ~/.bash_profile
alias composer7='php7 D:/composer7/composer.phar'
source ~/.bash_profile
  • 查看php7和composer7
1
2
php7 -v
composer7 -v

Powered by Hexo and Hexo-theme-hiker

Copyright © 2017 - 2023 Keep It Simple And Stupid All Rights Reserved.

访客数 : | 访问量 :