-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
113 lines (90 loc) · 3.53 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$install_requirements = <<SCRIPT
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug beanstalkd supervisor memcached php5-memcached
cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.idekey = "vagrant"
xdebug.scream=1
xdebug.cli_color=1
xdebug.show_local_vars=1
EOF
mysql -u root -proot -e"grant all on *.* to root@'192.168.33.1' IDENTIFIED BY 'root'" mysql
sudo a2enmod rewrite
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
sed -i "s/disable_functions = .*/disable_functions = /" /etc/php5/cli/php.ini
sed -i "s/#START=yes/START=yes/" /etc/default/beanstalkd
sed -i "s/127.0.0.1/0.0.0.0/" /etc/mysql/my.cnf
# add supervisor config for laravel beatstalk queue
SUPER=$(cat <<EOF
[program:bet-notification]
command=php artisan queue:work --daemon --queue=bet-notification --tries=1 --env=vagrant
directory=/vagrant
stdout_logfile=/vagrant/app/storage/logs/bet-notification_supervisord.log
redirect_stderr=true
autostart=true
autorestart=true
EOF
)
echo "${SUPER}" > /etc/supervisor/conf.d/bet-notification.conf
# restart services
sudo service mysql restart
sudo service apache2 restart
sudo service beantstalkd start
sudo service supervisor start
sudo service memcached start
# install composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# set php timezone
echo "Australia/Sydney" | sudo tee /etc/timezone
# auto change to project directory on login
echo "cd /vagrant" >> /home/vagrant/.bashrc
# install composer packages for project
cd /vagrant
composer install
# add project hosts to hosts file
echo "192.168.33.10 services.dev" | sudo tee -a /etc/hosts
echo "192.168.33.11 topbetta.dev" | sudo tee -a /etc/hosts
echo "192.168.33.12 serena.dev" | sudo tee -a /etc/hosts
echo "192.168.33.13 risk.dev" | sudo tee -a /etc/hosts
echo "192.168.33.14 puntersclubapi.dev" | sudo tee -a /etc/hosts
echo "192.168.33.15 api.toptippa.dev" | sudo tee -a /etc/hosts
echo "192.168.33.16 toptippa.dev" | sudo tee -a /etc/hosts
SCRIPT
# default website setup
$vhost_setup = <<SCRIPT
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant/public"
ServerName localhost
ServerAlias services.dev
<Directory "/vagrant/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", inline: $install_requirements
config.vm.provision "shell", inline: $vhost_setup
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network "forwarded_port", guest: 80, host: 8081
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]
config.vm.network "private_network", ip: "192.168.33.10"
end