如何告诉Deployer使用不同的PHP版本ssh'ed到我的共享主机?

问题描述 投票:0回答:1

我正在尝试使用Deployer将Laravel应用程序部署到我当地的~/Code/project_foo共享主机(使用laravel配方)。

关键是当我通过ssh连接到我的共享托管服务器时,默认的php -v版本是5.6.33。我确认我可以通过调用php70 -v甚至像/usr/local/bin/php70 whatever这样的整个路径来改变php版本。

关键是我不知道如何告诉部署者使用php70调用命令,否则composer install失败。

enter image description here

所以在终端我是Laravel项目的根目录,我只是打电话:

dep deploy

我的deploy.php很乱,很简单,但这只是一个概念证明。我想弄清楚一切然后我会让它看起来更好。

enter image description here

我检查了source code of the laravel recipe,我看到有:

{{bin/php}}

但我不知道如何覆盖该值以匹配我的主机告诉我使用的值:

/usr/local/bin/php70

请给我任何提示如何在连接到远程主机/服务器后强制脚本使用不同的PHP版本。

这是完整的脚本:

<?php
namespace Deployer;

require 'recipe/laravel.php';


//env('bin/php', '/usr/local/bin/php70'); // <- I thought that this will work but it doesn't change anything


// Project name
set('application', 'my_project');

// Project repository
set('repository', '[email protected]:xxx/xxx.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true); 

// Shared files/dirs between deploys 
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server 
add('writable_dirs', []);


// Hosts

host('xxx')
    ->user('xxx')
    ->set('deploy_path', '/home/slickpl/projects/xxx');

// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');
php laravel laravel-5 php-7 php-deployer
1个回答
4
投票

好的,我找到了解决方案。

我补充说(在require之后):

set('bin/php', function () {
    return '/usr/local/bin/php70';
});
© www.soinside.com 2019 - 2024. All rights reserved.