-
Notifications
You must be signed in to change notification settings - Fork 30
/
install.sh
680 lines (420 loc) · 16.9 KB
/
install.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
#!/bin/bash
# /*=================================
# = VARIABLES =
# =================================*/
INSTALL_NGINX_INSTEAD=0
WELCOME_MESSAGE='
MMMMMMMMMMMMMMMXl..........................cXMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMK:.::....................;c.:KMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMM0:.lc....................:l,;0MMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMO;.l:....................;l,,OMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMWx.;l;....................,l:.dWMMMMMMMMMMMMMM
MMMMMMMMMMMMMMNl.:l......................lc.lXMMMMMMMMMMMMMM
MMMMMMMMMMMMMM0;.lc......................:l,;OMMMMMMMMMMMMMM
MMMMMMMMMMMMMNd.;o;......................,l:.oNMMMMMMMMMMMMM
MMMMMMMMMMMMM0;.lc........................:l.;OMMMMMMMMMMMMM
MMMMMMMMMMMMNo.:l,.........................lc.lXMMMMMMMMMMMM
MMMMMMMMMMMWO,.lc..........................:l,,kWMMMMMMMMMMM
MMMMMMMMMMMXl.:l.....................;:::,..lc.cXMMMMMMMMMMM
MMMMMMMMMMMO,,l:..................,codxxxdc.;l;,kWMMMMMMMMMM
MMMMMMMMMMNd.:l,..,cloolc;......;ldxxxxxxxd:,lc.oNMMMMMMMMMM
MMMMMMMMMMNl.cl..lOKKKKK0Oxl;;:ldxxxxxxxxxxc.cl.cXMMMMMMMMMM
MMMMMMMMMMXl.cl.:OKKKKKKK0Oxooodxxxxxxxxxxxc.cl.cXMMMMMMMMMM
MMMMMMMMMMNd.;l,,dO0000Okdolllllodxxxxxxxxo,,l:.oNMMMMMMMMMM
MMMMMMMMMMM0:.cl.,ldddolllllllllllodxxxxxo;.cl.;OMMMMMMMMMMM
MMMMMMMMMMMWO;.cl,,:clllllllllllllllloooc,,cl,,kWMMMMMMMMMMM
MMMMMMMMMMMMW0:.:l:,,:cllllllllllllllc:,,:l:.:OWMMMMMMMMMMMM
MMMMMMMMMMMMMMXd;,:c:;,,;:cccccccc:;,,,:cc,,oKWMMMMMMMMMMMMM
MMMMMMMMMMMMMMMWKd;,:dkdl:;;;,,,;;:coxdc,;o0WMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMWO;.lXMWNXK00000KNWMNd.;kWMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMXo.;OWMMMMMMMMMMMMMMMKc.lXMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMNo.;OWMMMMMMMMMMMMMMMMM0:.lXMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMNd.;kWMMMMMMMMMMMMMMMMMMM0:.oNMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMK:.oNMMMMMMMMMMMMMMMMMMMMWx.;0MMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMXl.:kXNWMMMMMMMMMMMMMMWWXOc.cXMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMXx:;;:clooddddddddoolc:;;:dKWMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMWXOdl:;,,.........,;:cdkXWMMMMMMMMMMMMMMMMM
______ _ ______ ______
/ _____) _ | | (____ \ (_____ \
( (____ ____ ___ _| |_ ____| |__ ____) ) ___ _ _ _____) )___ ___
\____ \ / ___) _ (_ _) ___) _ \ | __ ( / _ ( \ / ) | ____/ ___) _ \
_____) | (__| |_| || |( (___| | | | | |__) ) |_| ) X ( | | | | | |_| |
(______/ \____)___/ \__)____)_| |_| |______/ \___(_/ \_) |_| |_| \___/
For help, please visit box.scotch.io or scotch.io. Follow us on Twitter @scotch_io and @whatnicktweets.
'
reboot_webserver_helper() {
if [ $INSTALL_NGINX_INSTEAD != 1 ]; then
sudo service apache2 restart
fi
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
sudo systemctl restart php7.2-fpm
sudo systemctl restart nginx
fi
echo 'Rebooting your webserver'
}
# /*=========================================
# = CORE / BASE STUFF =
# =========================================*/
sudo apt-get update
# The following is "sudo apt-get -y upgrade" without any prompts
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
sudo apt-get install -y build-essential
sudo apt-get install -y tcl
sudo apt-get install -y software-properties-common
sudo apt-get install -y python-software-properties
sudo apt-get -y install vim
sudo apt-get -y install git
# Weird Vagrant issue fix
sudo apt-get install -y ifupdown
# /*======================================
# = INSTALL APACHE =
# ======================================*/
if [ $INSTALL_NGINX_INSTEAD != 1 ]; then
# Install the package
sudo add-apt-repository -y ppa:ondrej/apache2 # Super Latest Version
sudo apt-get update
sudo apt-get -y install apache2
# Remove "html" and add public
mv /var/www/html /var/www/public
# Clean VHOST with full permissions
MY_WEB_CONFIG='<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/public">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>'
echo "$MY_WEB_CONFIG" | sudo tee /etc/apache2/sites-available/000-default.conf
# Squash annoying FQDN warning
echo "ServerName scotchbox" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servername
# Enabled missing h5bp modules (https://github.com/h5bp/server-configs-apache)
sudo a2enmod expires
sudo a2enmod headers
sudo a2enmod include
sudo a2enmod rewrite
sudo service apache2 restart
fi
# /*=====================================
# = INSTALL NGINX =
# =====================================*/
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
# Install Nginx
sudo add-apt-repository -y ppa:ondrej/nginx-mainline # Super Latest Version
sudo apt-get update
sudo apt-get -y install nginx
sudo systemctl enable nginx
# Remove "html" and add public
mv /var/www/html /var/www/public
# Make sure your web server knows you did this...
MY_WEB_CONFIG='server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/public;
index index.html index.htm index.nginx-debian.html;
server_name _;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}'
echo "$MY_WEB_CONFIG" | sudo tee /etc/nginx/sites-available/default
sudo systemctl restart nginx
fi
# /*===================================
# = INSTALL PHP =
# ===================================*/
# Install PHP
sudo add-apt-repository -y ppa:ondrej/php # Super Latest Version (currently 7.2)
sudo apt-get update
sudo apt-get install -y php7.2
# Make PHP and Apache friends
if [ $INSTALL_NGINX_INSTEAD != 1 ]; then
sudo apt-get -y install libapache2-mod-php
# Add index.php to readable file types
MAKE_PHP_PRIORITY='<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>'
echo "$MAKE_PHP_PRIORITY" | sudo tee /etc/apache2/mods-enabled/dir.conf
sudo service apache2 restart
fi
# Make PHP and NGINX friends
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
# FPM STUFF
sudo apt-get -y install php7.2-fpm
sudo systemctl enable php7.2-fpm
sudo systemctl start php7.2-fpm
# Fix path FPM setting
echo 'cgi.fix_pathinfo = 0' | sudo tee -a /etc/php/7.2/fpm/conf.d/user.ini
sudo systemctl restart php7.2-fpm
# Add index.php to readable file types and enable PHP FPM since PHP alone won't work
MY_WEB_CONFIG='server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}'
echo "$MY_WEB_CONFIG" | sudo tee /etc/nginx/sites-available/default
sudo systemctl restart nginx
fi
# /*===================================
# = PHP MODULES =
# ===================================*/
# Base Stuff
sudo apt-get -y install php7.2-common
sudo apt-get -y install php7.2-dev
# Common Useful Stuff (some of these are probably already installed)
sudo apt-get -y install php7.2-bcmath
sudo apt-get -y install php7.2-bz2
sudo apt-get -y install php7.2-cgi
sudo apt-get -y install php7.2-cli
sudo apt-get -y install php7.2-fpm
sudo apt-get -y install php7.2-gd
sudo apt-get -y install php7.2-imap
sudo apt-get -y install php7.2-intl
sudo apt-get -y install php7.2-json
sudo apt-get -y install php7.2-mbstring
sudo apt-get -y install php7.2-odbc
sudo apt-get -y install php-pear
sudo apt-get -y install php7.2-pspell
sudo apt-get -y install php7.2-tidy
sudo apt-get -y install php7.2-xmlrpc
sudo apt-get -y install php7.2-zip
# Enchant
sudo apt-get -y install libenchant-dev
sudo apt-get -y install php7.2-enchant
# LDAP
sudo apt-get -y install ldap-utils
sudo apt-get -y install php7.2-ldap
# CURL
sudo apt-get -y install curl
sudo apt-get -y install php7.2-curl
# IMAGE MAGIC
sudo apt-get -y install imagemagick
sudo apt-get -y install php7.2-imagick
# /*===========================================
# = CUSTOM PHP SETTINGS =
# ===========================================*/
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
PHP_USER_INI_PATH=/etc/php/7.2/fpm/conf.d/user.ini
else
PHP_USER_INI_PATH=/etc/php/7.2/apache2/conf.d/user.ini
fi
echo 'display_startup_errors = On' | sudo tee -a $PHP_USER_INI_PATH
echo 'display_errors = On' | sudo tee -a $PHP_USER_INI_PATH
echo 'error_reporting = E_ALL' | sudo tee -a $PHP_USER_INI_PATH
echo 'short_open_tag = On' | sudo tee -a $PHP_USER_INI_PATH
reboot_webserver_helper
# Disable PHP Zend OPcache
echo 'opache.enable = 0' | sudo tee -a $PHP_USER_INI_PATH
# Absolutely Force Zend OPcache off...
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
sudo sed -i s,\;opcache.enable=0,opcache.enable=0,g /etc/php/7.2/fpm/php.ini
else
sudo sed -i s,\;opcache.enable=0,opcache.enable=0,g /etc/php/7.2/apache2/php.ini
fi
reboot_webserver_helper
# /*================================
# = PHP UNIT =
# ================================*/
sudo wget https://phar.phpunit.de/phpunit-6.1.phar
sudo chmod +x phpunit-6.1.phar
sudo mv phpunit-6.1.phar /usr/local/bin/phpunit
reboot_webserver_helper
# /*=============================
# = MYSQL =
# =============================*/
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 -y install mysql-server
sudo mysqladmin -uroot -proot create scotchbox
sudo apt-get -y install php7.2-mysql
reboot_webserver_helper
# /*=================================
# = PostreSQL =
# =================================*/
sudo apt-get -y install postgresql postgresql-contrib
echo "CREATE ROLE root WITH LOGIN ENCRYPTED PASSWORD 'root';" | sudo -i -u postgres psql
sudo -i -u postgres createdb --owner=root scotchbox
sudo apt-get -y install php7.2-pgsql
reboot_webserver_helper
# /*==============================
# = SQLITE =
# ===============================*/
sudo apt-get -y install sqlite
sudo apt-get -y install php7.2-sqlite3
reboot_webserver_helper
# /*===============================
# = MONGODB =
# ===============================*/
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo tee /lib/systemd/system/mongod.service <<EOL
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl enable mongod
sudo service mongod start
# Enable it for PHP
sudo pecl install mongodb
sudo apt-get install -y php7.2-mongodb
reboot_webserver_helper
# /*================================
# = COMPOSER =
# ================================*/
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
php composer-setup.php --quiet
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod 755 /usr/local/bin/composer
# /*==================================
# = BEANSTALKD =
# ==================================*/
sudo apt-get -y install beanstalkd
# /*==============================
# = WP-CLI =
# ==============================*/
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
# /*=============================
# = DRUSH =
# =============================*/
wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.5.1/drush.phar
sudo chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush
# /*=============================
# = NGROK =
# =============================*/
sudo apt-get install ngrok-client
# /*==============================
# = NODEJS =
# ==============================*/
sudo apt-get -y install nodejs
sudo apt-get -y install npm
# Use NVM though to make life easy
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 8.9.4
# Node Packages
sudo npm install -g gulp
sudo npm install -g grunt
sudo npm install -g bower
sudo npm install -g yo
sudo npm install -g browser-sync
sudo npm install -g browserify
sudo npm install -g pm2
sudo npm install -g webpack
# /*============================
# = YARN =
# ============================*/
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get -y install yarn
# /*============================
# = RUBY =
# ============================*/
sudo apt-get -y install ruby
sudo apt-get -y install ruby-dev
# Use RVM though to make life easy
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.5.0
rvm use 2.5.0
# /*=============================
# = REDIS =
# =============================*/
sudo apt-get -y install redis-server
sudo apt-get -y install php7.2-redis
reboot_webserver_helper
# /*=================================
# = MEMCACHED =
# =================================*/
sudo apt-get -y install memcached
sudo apt-get -y install php7.2-memcached
reboot_webserver_helper
# /*==============================
# = GOLANG =
# ==============================*/
sudo add-apt-repository -y ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get -y install golang-go
# /*===============================
# = MAILHOG =
# ===============================*/
sudo wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
sudo chmod +x ~/mailhog
# Enable and Turn on
sudo tee /etc/systemd/system/mailhog.service <<EOL
[Unit]
Description=MailHog Service
After=network.service vagrant.mount
[Service]
Type=simple
ExecStart=/usr/bin/env /home/vagrant/mailhog > /dev/null 2>&1 &
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl enable mailhog
sudo systemctl start mailhog
# Install Sendmail replacement for MailHog
sudo go get github.com/mailhog/mhsendmail
sudo ln ~/go/bin/mhsendmail /usr/bin/mhsendmail
sudo ln ~/go/bin/mhsendmail /usr/bin/sendmail
sudo ln ~/go/bin/mhsendmail /usr/bin/mail
# Make it work with PHP
if [ $INSTALL_NGINX_INSTEAD == 1 ]; then
echo 'sendmail_path = /usr/bin/mhsendmail' | sudo tee -a /etc/php/7.2/fpm/conf.d/user.ini
else
echo 'sendmail_path = /usr/bin/mhsendmail' | sudo tee -a /etc/php/7.2/apache2/conf.d/user.ini
fi
reboot_webserver_helper
# /*=======================================
# = WELCOME MESSAGE =
# =======================================*/
# Disable default messages by removing execute privilege
sudo chmod -x /etc/update-motd.d/*
# Set the new message
echo "$WELCOME_MESSAGE" | sudo tee /etc/motd
# /*===================================================
# = FINAL GOOD MEASURE, WHY NOT =
# ===================================================*/
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
reboot_webserver_helper
# /*====================================
# = YOU ARE DONE =
# ====================================*/
echo 'Booooooooom! We are done. You are a hero. I love you.'