【问题标题】:Wordpress + Vagrant : The SSH command responded with a non-zero exit statusWordpress + Vagrant:SSH 命令以非零退出状态响应
【发布时间】:2017-02-22 07:22:09
【问题描述】:

我正在关注this tutorial 用 vagrant 设置 Wordpress。但它似乎不起作用。

我得到以下信息:

==> default: gpg: 
==> default: keyring `/tmp/tmpJZaDWh/secring.gpg' created
==> default: gpg: 
==> default: keyring `/tmp/tmpJZaDWh/pubring.gpg' created
==> default: gpg: 
==> default: requesting key E5267A6C from hkp server keyserver.ubuntu.com
==> default: gpg: 
==> default: /tmp/tmpJZaDWh/trustdb.gpg: trustdb created
==> default: gpg: 
==> default: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur?" imported
==> default: gpg: 
==> default: Total number processed: 1
==> default: gpg: 
==> default:               imported: 1
==> default:   (RSA: 1)

然后:

==> default: E
==> default: : 
==> default: Unable to correct problems, you have held broken packages.
==> default: tee: 
==> default: /etc/php5/mods-available/xdebug.ini
==> default: : No such file or directory
==> default: xdebug.scream=1
==> default: xdebug.cli_color=1
==> default: xdebug.show_local_vars=1
==> default: sudo
==> default: : 
==> default: a2enmod: command not found
==> default: sed: can't read /etc/php5/apache2/php.ini: No such file or directory
==> default: sed: can't read /etc/php5/apache2/php.ini: No such file or directory
==> default: sed: can't read /etc/php5/cli/php.ini: No such file or directory
==> default: apache2: unrecognized service
==> default: /tmp/vagrant-shell: line 26: php: command not found
==> default: mv: 
==> default: cannot stat `composer.phar'
==> default: : No such file or directory
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

我不知道这实际上意味着什么,也不知道问题出在哪里。流浪者确实可以工作,但我之前已经能够启动一个流浪者盒子而没有错误。正是在上述教程的上下文中,我遇到了问题。

编辑: 按照这里的建议,我更改了我的 vagrantfile 和 install.sh。但是,我仍然遇到同样的错误。这是我修改过的文件:

流浪文件

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/precise64"
  config.vm.network :private_network, ip: "192.168.33.21"
  config.vm.provision :shell, :path => "install.sh"
  config.vm.synced_folder ".", "/var/www"

end

install.sh

sudo apt-get update

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'

sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update

sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug

cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
xdebug.scream=1
xdebug.cli_color=1
xdebug.show_local_vars=1
EOF

sudo a2enmod rewrite

sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
sed -i "s/disable_functions = .*/disable_functions = /" /etc/php5/cli/php.ini

sudo service apache2 restart

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

【问题讨论】:

    标签: php wordpress ssh vagrant


    【解决方案1】:

    我觉得这个教程有点老了,肯定包含一些过时的信息。

    使用最新的盒子

    教程中使用的precision64 box最近2年没有更新过,你应该使用这个box的更新版本,所以替换

      config.vm.box = "precise64"
      config.vm.box_url = "http://files.vagrantup.com/precise64.box"
    

    单行

      config.vm.box = "ubuntu/precise64"
    

    vagrant 会自动从图集下载盒子

    php repo 已过时

    示例中使用的 php repo 是 deprecated

    此 PPA 将被弃用,请使用 ppa:ondrej/php

    如果您需要其他 PHP 版本,请使用:

      PHP 5.4: ppa:ondrej/php5-oldstable (Ubuntu 12.04 LTS)
      PHP 5.5, PHP 5.6 and PHP 7.0: ppa:ondrej/php (Ubuntu 14.04 LTS - Ubuntu 16.04 LTS)
    

    所以 install.sh 脚本将是

    sudo apt-get update
    
    sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
    sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
    
    sudo apt-get install -y vim curl python-software-properties
    sudo add-apt-repository -y ppa:ondrej/php5-oldstable
    sudo apt-get update
    
    sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug
    
    sudo a2enmod rewrite
    
    sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
    sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
    sed -i "s/disable_functions = .*/disable_functions = /" /etc/php5/cli/php.ini
    
    sudo service apache2 restart
    
    curl -sS https://getcomposer.org/installer | php
    sudo mv composer.phar /usr/local/bin/composer
    

    通过这 2 项更改,它应该已经让你处于更好的状态 - 它会开始,但正如它现在所说的相当旧的帖子,如果你正在寻找开发,你应该考虑升级堆栈 -

    【讨论】:

    • 非常感谢。我不明白第二步到底该做什么(php repo 已过时)?
    • install.sh 脚本中有 sudo add-apt-repository -y ppa:ondrej/php5 这个 repo 已过时,因此您需要将其替换为消息中的 2 个值之一
    • 对不起,我想我还是没有跟上,我是一个绝对的初学者。我已将 'sudo add-apt-repository -y ppa:ondrej/php5' 替换为 'sudo add-apt-repository -y ppa:ondrej/php',但它仍然给我一个错误,所以我想我不明白你正确吗?您指的是消息中的哪两个值?
    • 我用ppa:ondrej/phpppa:ondrej/php 都试过了,但它给了我同样的错误。可以肯定的是,我已将 sudo add-apt-repository -y ppa:ondrej/php5 替换为 sudo add-apt-repository -y ppa:ondrej/php
    • 真的吗? oldstable 很奇怪,它会起作用 - 重新创建您的虚拟机,运行 vagrant destroy &amp;&amp; vagrant up 以销毁并重新创建您的虚拟机
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-28
    • 2021-02-15
    • 2019-02-09
    • 1970-01-01
    相关资源
    最近更新 更多