3 echo "Using apt-get. Installing apache2 on one of the following : Debian, Ubuntu, Mint"
8 if mkdir "${LOCK}" &>/dev/null; then
9 echo "Apache take the lock"
12 echo "Waiting the end of one of our recipes..."
16 while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
17 echo "Waiting for other software managers to finish..."
21 sudo rm -f /var/lib/dpkg/lock
22 sudo apt-get update || (sleep 15; sudo apt-get update || exit ${1})
23 sudo apt-get install -y -q apache2 || exit ${1}
26 sudo /etc/init.d/apache2 stop
27 if [ ! -d $DOC_ROOT ]; then
28 eval "sudo mkdir -p $DOC_ROOT"
30 eval "sudo chown -R www-data:www-data $DOC_ROOT"
32 if [[ ("$PORT" == "$DEFAULT_PORT") ]]; then
33 echo "Use default port for Apache : $DEFAULT_PORT"
35 echo "Replacing port $DEFAULT_PORT with $PORT..."
36 sudo sed -i -e "s/$DEFAULT_PORT/$PORT/g" /etc/apache2/ports.conf || exit ${1}
39 echo "Change config of apache2"
40 if sudo test -f "/etc/apache2/sites-available/default"; then
41 echo "Change the DocumentRoot of apache2 on Ubuntu < 14.04"
42 sudo sed -i -e "s#DocumentRoot /var/www#DocumentRoot $DOC_ROOT#g" /etc/apache2/sites-available/default
44 if sudo test -f "/etc/apache2/sites-available/000-default.conf"; then
45 echo "Change the DocumentRoot of Apache2 on Ubuntu >= 14.04"
46 sudo sed -i -e "s#DocumentRoot /var/www/html#DocumentRoot $DOC_ROOT#g" /etc/apache2/sites-available/000-default.conf
49 sudo bash -c "echo ServerName localhost >> /etc/apache2/apache2.conf"
51 echo "Start apache2 whith new conf"
52 sudo /etc/init.d/apache2 start