2016-04-29 78 views
0

我使用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() { "[email protected]" 2>&1 | logger -t "${PROJECT}" > /dev/null; } 
ol() { echo "[${PROJECT_LOG}] [email protected]"; } 

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 -- [email protected]:~$

試過從VM啓動apache。這是輸出: enter image description here

+2

的根本原因'爲details' – jDo

+0

'apache2.service請參閱 「systemctl狀態apache2.service」 和 「journalctl -xe」 - LSB:Apache2的Web服務器 加載:加載( /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之前 Docs:man:systemd-sysv-generator(8) 進程:14280 ExecStop = /etc/init.d/apache2 stop(code = exited,status = 0/SUCCESS) 進程:14302 ExecStart =/etc/init.d/apache2 start(code = exited,status = 1/FAILURE) vagrant @ vagrant-ubuntu-wily-64:〜$ journalctl -xe 找不到日誌文件。 - 沒有條目 - vagrant @ vagrant-ubuntu-wily-64:〜$'' – Kevin

+0

最好在問題中包含錯誤/日誌消息,而不是將它們發佈爲註釋。它將保持格式化並使其他人稍後查找更容易/更快速。 – jDo

回答

2

當您更換DocumentRoot,你居然寫RootDocument等阿帕奇抱怨它沒有找到它,不希望重新啓動

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運行最有可能有一個條目中的d輸出應該指向你的錯誤