Kevin Aartsen Kevin Aartsen - 7 months ago 25
Bash Question

whats wrong my code?

Im using vagrant to setup my server. But I'm getting this error and i have no clue of what it could be.
In the provision file i have put this:

#!/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


but everytime i do vagrant up i keep getting errors.
these are the errors

=> 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


I have no clue what's wrong here.

adit:
i did the following:
systemctl status apache2.service


this was the output:

● 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)


Then i did:
journalctl -xe


This was the output:
No journal files were found. -- No entries -- vagrant@vagrant-ubuntu-wily-64:~$


Tried to start apache from the VM. This was the output:
enter image description here

Answer

when you replace your DocumentRoot, you actually write RootDocument and so apache complains it does not find it and does not want to restart

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

make sure to have

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

NB: for the journalctl -xe command you should make sure to run as sudo most probably there's an entry and the output should point you to the root cause of the error

Comments