【问题标题】:Vagrant not loading the right versionsVagrant 没有加载正确的版本
【发布时间】:2019-04-02 09:25:16
【问题描述】:

在我将我的 ansible playbooks php 版本从 5 更新到 7.2 和 xdebug 以匹配该版本之后。 我在我的 vagrant box 中运行 php -v 我得到了

PHP 7.2.11-3+ubuntu14.04.1+deb.sury.org+1 (cli)(构建时间:2018 年 10 月 25 日 08:20:21)(NTS) 版权所有 (c) 1997-2018 PHP 集团 Zend Engine v3.2.0,版权所有 (c) 1998-2018 Zend Technologies 使用 Zend OPcache v7.2.11-3+ubuntu14.04.1+deb.sury.org+1,版权所有 (c) 1999-2018,Zend Technologies 使用 Xdebug v2.6.1,版权所有 (c) 2002-2018,由 Derick Rethans 提供

但我的phpinfo();

PHP 版本 5.6.38-3+ubuntu14.04.1+deb.sury.org+1 这个程序使 Zend 脚本语言引擎的使用:Zend Engine v2.6.0, 版权所有 (c) 1998-2016 Zend Technologies Zend OPcache v7.0.6-dev,版权所有 (c) 1999-2016,Zend Technologies 使用 Xdebug v2.5.5,版权所有 (c) 2002-2017,作者 Derick Rethans

我的剧本

---

 name: Add ppa Repository
  sudo: yes
  apt_repository: repo=ppa:ondrej/{{ php.ppa }}

- name: Update apt
  sudo: yes
  apt: update_cache=yes

- name: Install php72
  sudo: yes
  apt: pkg=php7.2 state=latest

- name: Install php72-fpm
  sudo: yes
  apt: pkg=php5-fpm state=latest

- name: Install PHP Packages
  sudo: yes
  apt: pkg={{ item }} state=latest
  with_items: "{{php.packages}}"
  when: php.packages is defined

- name: Set date.timezone for CLI
  become: true
  lineinfile:
    dest: /etc/php/7.2/cli/php.ini
    regexp: "date.timezone ="
    line: "date.timezone = Europe/Berlin"

- name: Set date.timezone for apache php
  become: true
  lineinfile:
    dest: /etc/php/7.2/apache2/php.ini
    regexp: "date.timezone ="
    line: "date.timezone = Europe/Berlin"

- include: configure.yml
- include: pecl.yml

【问题讨论】:

  • 检查两个 phpinfos 中的 php 路径,或者输入哪个 php 来找到正在使用的那个#

标签: php ansible vagrant


【解决方案1】:

所以php -v 会告诉你你的 php CLI 运行在哪个版本的 php 上。因此 CLI 和 phpinfo 中的版本冲突。其次,任务“安装php72-fpm”的“pkg”设置为“php5-fpm”;试着把它切换到你需要的版本,看看你是怎么玩的。

【讨论】:

  • 我试过了,但还是不行……我不确定是否有缓存?流浪汉?还是我的其他想法某些根被覆盖?
  • 所以我假设安装新版本的 PHP 没有问题?如果没有,您是否尝试重新启动服务?根据您的系统,这可以通过多种方式完成。对于 Ubuntu,它是 sudo service php7.2-fpm restart
  • 不,我安装它没有任何问题,只是没有从我的盒子“转移”到我的本地服务器。重启没有帮助
  • 当你说'不转移'时,你的意思是phpinfo()仍然显示错误的版本?
  • 完全正确。甚至我的 vagrant box 也显示了正确的版本。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-09
  • 2015-10-19
  • 1970-01-01
  • 2023-04-06
  • 1970-01-01
  • 1970-01-01
  • 2023-04-08
相关资源
最近更新 更多