什么错了我的代码?

时间:2016-04-29 12:24:20

标签: shell vagrant

我正在使用vagrant来设置我的服务器。但我得到了这个错误,我不知道它可能是什么。 在提供文件中我已经把它:

#!/usr/bin/env bash

PROJECT="foundation"
PROJECT_LOG="foundation"

MYSQL_PASSWORD="wachtwoord"

set -o nounset -o errexit -o pipefail -o errtrace

error() {
   local sourcefile=$1
   local lineno=$2
   echo "ERROR at ${sourcefile}:${lineno}; Last logs:"
   grep "${PROJECT}" /var/log/syslog | tail -n 20
}

trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

oe() { "$@" 2>&1 | logger -t "${PROJECT}" > /dev/null; }
ol() { echo "[${PROJECT_LOG}] $@"; }

export DEBIAN_FRONTEND=noninteractive

ol 'Updating repository caches'
oe sudo apt-get -q -y update

ol 'Adding apt repositories'
oe sudo apt-get -q -y install python-software-properties
oe sudo add-apt-repository ppa:ondrej/php5-5.6

ol 'Updating repository caches (second time)'
oe sudo apt-get -q -y update

ol "Installing misc packages"
oe sudo apt-get -q -y install language-pack-nl

ol 'Installing Apache 2'
oe sudo apt-get -q -y install apache2
oe sudo systemctl restart apache2
oe sudo systemctl status apache2

ol 'changing root directory'
oe sudo sed -i "s/DocumentRoot.*/RootDocument \/var\/www/" /etc/apache2/sites-available/000-default.conf

ol "Installing PHP"
oe sudo apt-get -q -y install php5 libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache

ol 'Restarting Apache 2'
oe sudo systemctl restart apache2
oe sudo systemctl status apache2

ol "Installing MySQL"
oe sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password ${MYSQL_PASSWORD}"
oe sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password ${MYSQL_PASSWORD}"
oe sudo apt-get -q -y install mysql-server mysql-client
oe sudo systemctl restart mysql
oe sudo systemctl status mysql

但每次我做流浪汉我都会遇到错误。 这些是错误

=> default: [foundation] Updating repository caches
==> default: [foundation] Adding apt repositories
==> default: [foundation] Updating repository caches (second time)
==> default: [foundation] Installing misc packages
==> default: [foundation] Installing Apache 2
==> default: [foundation] Installing PHP
==> default: [foundation] changing root directory
==> default: [foundation] Restarting Apache 2
==> default: ERROR at /tmp/vagrant-shell:19; Last logs:
==> default: Apr 29 12:16:53 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-common].
==> default: Apr 29 12:16:53 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-variant_0].
==> default: Apr 29 12:16:53 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-variant_1].
==> default: Apr 29 12:16:53 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-variant_2].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-w_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en-wo_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_CA-variant_0].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_CA-variant_1].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_CA-w_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_CA-wo_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-ise-w_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-ise-wo_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-ize-w_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-ize-wo_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-variant_0].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_GB-variant_1].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_US-w_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: aspell-autobuildhash: processing: en [en_US-wo_accents-only].
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: Processing triggers for libapache2-mod-php5 (5.6.20+dfsg-1+deb.sury.org~wily+1) ...
==> default: Apr 29 12:16:54 vagrant-ubuntu-wily-64 foundation: Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
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

我不知道这里有什么问题。

硐: 我做了以下事情:systemctl status apache2.service

这是输出:

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─forking.conf
   Active: failed (Result: exit-code) since Fri 2016-04-29 12:34:51 UTC; 17s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 14280 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 14302 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

然后我做了:journalctl -xe

这是输出:No journal files were found. -- No entries -- vagrant@vagrant-ubuntu-wily-64:~$

尝试从VM启动apache。这是输出: enter image description here

1 个答案:

答案 0 :(得分:2)

当您替换DocumentRoot时,您实际上写了 RootDocument ,因此apache抱怨它找不到它并且不想重新启动

oe sudo sed -i "s/DocumentRoot.*/RootDocument \/var\/www/" /etc/apache2/sites-available/000-default.conf

确保

oe sudo sed -i "s/DocumentRoot.*/DocumentRoot \/var\/www/" /etc/apache2/sites-available/000-default.conf

注意:对于journalctl -xe命令,你应该确保以sudo运行,最有可能是一个条目,输出应该指出错误的根本原因