This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
/
vagrant.sh
executable file
·228 lines (203 loc) · 5.94 KB
/
vagrant.sh
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env bash
# Vagrant install file for Laravel 4 Bootstrap Starter Site
# https://github.com/andrewelkins/Laravel-4-Bootstrap-Starter-Site
#
# Adapted from https://github.com/philipbrown/vagrant-laravel
#
# License: MIT
# ----------------
# Configure and Update the box
# ----------------
# Adds Repositories and then updates
echo '- Adding packages for nginx, nodejs, and php...'
# Add nginx repo
add-apt-repository -y ppa:nginx/stable
# Add latestest Node
add-apt-repository ppa:richarvey/nodejs
# Add PHP 5.4
add-apt-repository ppa:ondrej/php5
echo '...done'
echo '- apt-get update...'
apt-get update
echo '...done'
# ----------------
# Install Screen & Vim
# ----------------
echo '- Installing screen vim unzip curl wget build-essential...'
apt-get install screen vim unzip curl wget build-essential -y --force-yes
echo '...done'
# ----------------
# Git
# ----------------
echo '- Installing git...'
apt-get install git-core -y --force-yes
echo '...done'
# ----------------
# Python properties
# ----------------
echo '- Installing python properties...'
apt-get install python-software-properties -y --force-yes
echo '...done'
# ----------------
# Nginx
# ----------------
echo '- Installing nginx...'
# Install
apt-get install nginx -y --force-yes
# Symlink /vagrant to /var/www
mkdir /var/www
ln -fs /vagrant /var/www/laravel
# Setup hosts file
VHOST=$(cat <<EOF
server {
listen 80 default_server;
root /vagrant/public;
index index.html index.htm index.php;
server_name laravel.local localhost;
access_log /var/log/nginx/localhost.laravel-access.log;
error_log /var/log/nginx/localhost.laravel-error.log error;
charset utf-8;
location / {
# URLs to attempt, including pretty ones.
try_files \$uri \$uri/ /index.php?\$query_string;
}
# Remove trailing slash to please routing system.
if (!-d \$request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~* \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
}
EOF
)
# Add nginx conf
echo "${VHOST}" > /etc/nginx/sites-available/laravel
# Remove default
sudo rm /etc/nginx/sites-enabled/default
# Create symlink
sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/laravel
# Reload nginx
service nginx reload
echo '...done'
# ----------------
# PHP 5.4
# ----------------
# Add add-apt-repository binary
apt-get install -y python-software-properties --force-yes
echo '- Installing php...'
# PHP-FPM
apt-get install -y php5-fpm --force-yes
# Command-Line Interpreter
apt-get install -y php5-cli --force-yes
# MySQL database connections directly from PHP
apt-get install -y php5-mysql --force-yes
# cURL is a library for getting files from FTP, GOPHER, HTTP server
apt-get install -y php5-curl --force-yes
# Module for MCrypt functions in PHP
apt-get install -y php5-mcrypt --force-yes
echo '...done'
echo '- Restart php-fpm and nginx...'
# PHP-FPM and ngnix restart
service php5-fpm restart
service nginx restart
echo '...done'
# ----------------
# cURL
# ----------------
echo '- Installing curl...'
apt-get install -y curl --force-yes
echo '...done'
# ----------------
# Mysql
# ----------------
# Ignore the post install questions
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password password'
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password password'
# Install MySQL quietly
echo '- Installing mysql...'
apt-get -q -y install mysql-server-5.5 mysql-client-5.5 --force-yes
echo '...done'
# ----------------
# Node.js
# ----------------
echo '- Installing node...'
apt-get install nodejs npm -y --force-yes
echo '...done'
# Bower (Frontend Package Manager)
# ---
echo '- Installing bower...'
npm install -g bower
echo '...done'
echo '- Installing grunt...'
npm install -g grunt-cli
echo '...done'
# --------------
# pip & HTTPie
# --------------
echo '- Installing pip...'
curl -s http://python-distribute.org/distribute_setup.py | python
easy_install pip >/dev/null
echo '...done'
echo '- Installing HTTPie...'
pip install --upgrade httpie >/dev/null
rm distribute-0.6.48.tar.gz
echo '...done'
# ----------------
# Install Composer
# ----------------
echo '- Installing composer...'
curl -s https://getcomposer.org/installer | php
# Make Composer available globally
mv composer.phar /usr/local/bin/composer
echo '...done'
# ----------------
# Install PHPUnit
# ----------------
echo 'Installing PHPUnit...'
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit
echo '...done'
# ----------------
# Laravel stuff
# ----------------
# Load Composer packages
cd /var/www/laravel
composer install --dev
# Set up the database
echo "CREATE DATABASE IF NOT EXISTS laravel" | mysql -u root -ppassword
echo "CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'" | mysql -u root -ppassword
echo "GRANT ALL PRIVILEGES ON laravel.* TO 'user'@'localhost' IDENTIFIED BY 'password'" | mysql -u root -ppassword
# Set up the database
php artisan migrate --env=local
# Seed db
php artisan db:seed --env=local
# Set key
php artisan key:generate
php artisan key:generate --env=local
# ----------------
# Finalize
# ----------------
# Set permissions
echo '- Set permissions...'
chgrp -R www-data /vagrant
chmod -R 777 /vagrant/app/storage
echo '...done'
# Notify
echo ''
echo ''
echo '----------------------------------------------'
echo ' Navigate to http://192.168.50.5 on host OS'
echo '----------------------------------------------'
echo ''
echo ' Emails sent will be written to the application logs.'
echo ' - This can be changed in app/config/local/mail.php'
echo ''
echo ''