envdev/lamp-trusty64/bootstrap.sh
2014-12-12 16:31:18 +01:00

86 lines
3.1 KiB
Bash

#!/usr/bin/env bash
sudo apt-get -y install htop unzip
# Installation MariaDB
if [ ! -f /etc/mysql/vagrant ]
then
MARIADB_VERSION='10.0'
MYSQL_PASS='scores'
debconf-set-selections <<< "mariadb-server-$MARIADB_VERSION mysql-server/root_password password $MYSQL_PASS"
debconf-set-selections <<< "mariadb-server-$MARIADB_VERSION mysql-server/root_password_again password $MYSQL_PASS"
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://nwps.ws/pub/mariadb/repo/10.0/ubuntu trusty main'
sudo apt-get update
sudo apt-get -y install mariadb-server
#sudo sed -i -e 's/datadir = \/var\/lib\/mysql/datadir = \/home\/vhosts\/mysql/g' /etc/mysql/my.cnf
sudo sed -i "s/bind-address = 127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
sudo service mysql restart
mysql -hlocalhost -uroot -pscores < /vagrant/data/pma.sql
sudo touch /etc/mysql/vagrant
fi
# Installation
if [ ! -f /usr/bin/php5 ]
then
sudo apt-get update
sudo apt-get install -y apache2 mysql-client-5.5 php5 php5-apcu php5-curl php5-xmlrpc php5-xsl php5-mysqlnd
sudo a2enmod autoindex deflate expires headers rewrite
fi
# Installation phpMyAdmin
PHPMYADMIN_VERSION='4.3.1'
if [ ! -d "/home/vhosts/phpMyAdmin-$PHPMYADMIN_VERSION-all-languages" ]
then
if [ -f "/vagrant/data/phpMyAdmin-$PHPMYADMIN_VERSION-all-languages.zip" ]
then
unzip "/vagrant/data/phpMyAdmin-$PHPMYADMIN_VERSION-all-languages.zip" -d /home/vhosts/
mysql -hlocalhost -uroot -pscores < "/home/vhosts/phpMyAdmin-$PHPMYADMIN_VERSION-all-languages/examples/create_tables.sql"
cp /vagrant/data/config.inc.php "/home/vhosts/phpMyAdmin-$PHPMYADMIN_VERSION-all-languages/"
fi
fi
# Installation Wkhtmltopdf
if [ ! -f /usr/local/bin/wkhtmltopdf ]
then
sudo dpkg -i /vagrant/data/wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo apt-get -f install -y
fi
# Configuration Apache
if [ ! -f /etc/apache2/conf-available/httpd.conf ]
then
sudo cp /vagrant/data/httpd.conf /etc/apache2/conf-available/
sudo a2enconf httpd
sudo mkdir /home/vhosts/apachelog
sudo mkdir /home/vhosts/test
fi
# Configuration PHP / Apache
sudo sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/apache2/php.ini
sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/apache2/php.ini
sudo sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php5/apache2/php.ini
sudo sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php5/apache2/php.ini
# Configuration PHP / CLI
sudo sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/cli/php.ini
sudo sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/cli/php.ini
#Disable all website
cd /etc/apache2/sites-available/
for f in *.conf; do sudo a2dissite $f; done;
sudo a2ensite 000-default.conf
# Copy Vhosts files
cd /vagrant/vhosts/
for f in *.conf; do
if [ -f $f ]
then
sudo cp -f $f /etc/apache2/sites-available/;
sudo a2ensite $f;
fi
done;
# Restart apache
sudo service apache2 restart