Homestead PHP版本错误

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

我正在尝试为Laravel 5.4.36制作一个无所事事的宅基服务器。这样我就可以练习在本地将主网站升级到最新的laravel版本。

服务器正确启动,但是我期望/需要PHP 7.0版。相反,当我在SSH终端中键入“ php --version”时,得到的版本是7.2.3。该文档说homestead 5.2.0应该安装PHP版本7.0,但不是。 (https://laravel.com/docs/5.2/homestead

键入“ php artisan --version”将返回预期的5.4.36 laravel版本...

关于如何解决此问题的想法?是否可以降级php版本并指定7.0?

这是我的Homestead.yaml文件...

ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
version: 5.2.0
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: 'C:\Users\Rick\Desktop\MyWebsite'
        to: /home/vagrant/code
sites:
    -
        map: mywebsite.test
        to: /home/vagrant/code/public
    -
        map: sub.mywebsite.test
        to: /home/vagrant/code/public
databases:
    - homestead
    - mywebsite
features:
    -
        mariadb: false
    -
        ohmyzsh: false
    -
        webdriver: false
name: mywebsite
hostname: www.mywebsite.test
php laravel homestead
1个回答
1
投票

Homestead有多个版本的PHP。如果查看~/.bash_aliases,应该看到几行是这样的:

function php70() {
    sudo update-alternatives --set php /usr/bin/php7.0
    sudo update-alternatives --set php-config /usr/bin/php-config7.0
    sudo update-alternatives --set phpize /usr/bin/phpize7.0
}

function php71() {
    sudo update-alternatives --set php /usr/bin/php7.1
    sudo update-alternatives --set php-config /usr/bin/php-config7.1
    sudo update-alternatives --set phpize /usr/bin/phpize7.1
}

function php72() {
    sudo update-alternatives --set php /usr/bin/php7.2
    sudo update-alternatives --set php-config /usr/bin/php-config7.2
    sudo update-alternatives --set phpize /usr/bin/phpize7.2
}

function php73() {
    sudo update-alternatives --set php /usr/bin/php7.3
    sudo update-alternatives --set php-config /usr/bin/php-config7.3
    sudo update-alternatives --set phpize /usr/bin/phpize7.3
}

在命令行上键入php70,它将切换命令行版本。

对于Web版本,您需要手动更新nginx配置文件,或者将PHP版本添加到映射中:

 map: mywebsite.test
 to: /home/vagrant/code/public
 php: "7.0"

您必须销毁该盒子并重新启动它才能重新加载Homestead文件。

© www.soinside.com 2019 - 2024. All rights reserved.