-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinst.sh
760 lines (678 loc) · 28.3 KB
/
inst.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
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
#!/bin/bash
# you have write permissions there. set RETAIN_NUM_LINES to the
###################################################################
## ##
## ##
## Down below, it's a mess... ##
## Now it'll try to do it's best. ##
## ##
## ##
###################################################################
# A bit of cleanup first, just in case there're old stuff #
rm -r ~/ngx-build ~/src-build ~/nginx-package ~/Time* ~/Install.log
###################################################################
### Setup Logging
LOGFILE=~/Install.log
RETAIN_NUM_LINES=10
function logsetup {
TMP=$(tail -n $RETAIN_NUM_LINES $LOGFILE 2>/dev/null) && echo "${TMP}" > $LOGFILE
exec > >(tee -a $LOGFILE)
exec 2>&1
}
function log {
echo "[$(date)]: $*"
}
logsetup
### Logging started
# Yellow
function show_progress ()
{
echo $(tput setaf 3)$@$(tput sgr0)
}
# Torquise
function show_progress_info ()
{
echo $(tput setaf 6)$@$(tput sgr0)
}
# Red color
function show_progress_error ()
{
echo $(tput setaf 1)$@$(tput sgr0)
}
# Red Background color
function show_progress_error2 ()
{
echo $(tput setb 4)$@$(tput sgr0)
}
# Loader
function show_progress_loader ()
{
echo $(tput setb 4)$(tput setaf 1)$@$(tput sgr0)
}
# Checking permissions
if [[ $EUID -ne 0 ]]; then
show_progress_error "You need root permissions to run the script."
exit 1
fi
readonly LINUX_DISTRO=$(lsb_release -i |awk '{print $3}')
readonly DEBIAN_VERSION=$(lsb_release -sc)
LINUX_ARCH=$(uname -m)
# Check lsb_release
if [ ! -x /usr/bin/lsb_release ]; then
show_progress "Installing lsb-release."
apt-get -y --force-yes install lsb-release &>> /dev/null
fi
# Check Linux distro
if [ "$LINUX_DISTRO" != "Ubuntu" ] && [ "$LINUX_DISTRO" != "Debian" ]; then
show_progress_error "Sorry, only Debian 7 and Ubuntu 14.04 is supported as of now"
exit 1
fi
show_progress "The script will terminate if any error to happen."
set -e
# Some systems problems with locales. So lets try to add them just to run smoother.
show_progress "Setting system locales. If they are erroneous MariaDB install just might fail"
dpkg-reconfigure locales
LANGUAGE=en_US.UTF-8
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_MESSAGES=en_US.UTF-8
locale-gen en_US.UTF-8
update-locale en_US.UTF-8
. /etc/default/locale
# Remove any existing packages:
show_progress "Doing a system upgrade and removing ffmpeg files if there any."
apt-get -y --force-yes dist-upgrade >> /dev/null
apt-get -y --force-yes remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm >> /dev/null
apt-get -y --force-yes install software-properties-common python-software-properties >> /dev/null
#Lets calculate how much time is spent
# We don't need this apt-get dist-upgrade process to be counted. So, the timer starts here.
START=$(date +%s)
echo $START > ~/Time.Vars
# Let's install what's needed...
if [ "$LINUX_DISTRO" == "Debian" ]; then
#Debian
show_progress "Adding multimedia repository and doing an apt-get update."
add-apt-repository -y 'deb http://www.deb-multimedia.org wheezy main non-free'
apt-get update
apt-get -y --force-yes install deb-multimedia-keyring libswresample0
elif [ "$LINUX_DISTRO" == "Ubuntu" ]; then
#Ubuntu
show_progress "Adding Ubuntu repository for FFMpeg and installing Ubuntu only stuff"
apt-add-repository multiverse
add-apt-repository -y ppa:jon-severinsson/ffmpeg
apt-get update
apt-get -y --force-yes install libglib2.0-dev libfontconfig1-dev libtiff4-dev libexif-dev
fi
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)..."
apt-get -y --force-yes install build-essential checkinstall git libfaac-dev libjack-jackd2-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)......."
apt-get -y --force-yes install libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1).........."
apt-get -y --force-yes install libvorbis-dev texi2html zlib1g-dev autoconf automake g++ bzip2 libfreetype6-dev libgpac-dev libtool pkg-config >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)............."
apt-get -y --force-yes install libssl1.0.0 libssl-dev libxvidcore-dev libxvidcore4 libass-dev librtmp-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)................"
apt-get -y --force-yes install libpcre3 libpcre3-dev unzip tar zip libpcrecpp0 >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)..................."
apt-get -y --force-yes install libreadline-dev libncurses5-dev perl make libjpeg-dev libjpeg-progs devscripts graphicsmagick-imagemagick-compat >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)......................"
apt-get -y --force-yes install graphicsmagick-libmagick-dev-compat libpam0g-dev libpng-dev libpng12-0 libpng12-dev libxml2-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)........................."
apt-get -y --force-yes install libtiff-dev libgif-dev libgeoip1 libxslt1.1 libxslt-dev openssl libgd2-xpm-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)............................"
apt-get -y --force-yes install libperl-dev libjpeg8-dev libcdio-cdda1 libcdio-paranoia1 libcdio13 libpostproc52 libgsm1-dev libbz2-dev >> /dev/null
show_progress_info "Installing necessary packages apt-get update, please wait $(tput setb 4)$(tput setaf 1)..............................."
apt-get -y --force-yes install libavfilter-dev libavcodec-dev libavutil-dev libavdevice-dev libavformat-dev libswscale-dev libgeoip-dev libsdl1.2-dev libva-dev libvdpau-dev >> /dev/null
show_progress "Start FFMpeg Installation"
show_progress "Depending on your CPU this might take a long while"
##################################################################Start FFMPEG
mkdir -p ~/src-build/build-ffmpeg
mkdir -p ~/ngx-build/
#apt-get -y --force-yes install yasm
show_progress " Installing yasm"
################################### First, install yasm
# YASM refused to install on ppc64le system. At least it broke the script. So let me try fixing it.
if [ "$LINUX_ARCH" != "x86_64" ] && [ "$LINUX_ARCH" != "i386" ] && [ "$LINUX_ARCH" != "i486" ] && [ "$LINUX_ARCH" != "amd64" ] && [ "$LINUX_ARCH" != "x86" ]; then
show_progress_error "Downloading YASM from the repository since we dont know your system architecture"
else
cd ~/src-build/build-ffmpeg
git clone git://github.com/yasm/yasm.git
cd yasm
./autogen.sh x86_64 i386 amd64
# ./configure x86_64 i386 amd64
make
checkinstall --pkgname=yasm --pkgversion="1.3.0" --backup=no \
--deldoc=yes --fstrans=no --default
fi
show_progress " Installing libx246"
################################### libx264
cd ~/src-build/build-ffmpeg
# They have git but I had connectivity errors with them so..
# git clone --depth 1 git://git.videolan.org/x264
#cd x264
# Check Linux distro
# On RunAbove Power8 systems due to system bein ppc64le the script didn't work. So, here's my workaround.
# if [[ $LINUX_ARCH == "x86_64" ]] && [[ $LINUX_ARCH == "i386" ]] && [[ $LINUX_ARCH == "i486" ]] && [[ $LINUX_ARCH == "amd64" ]] && [[ $LINUX_ARCH == "x86" ]] && [[ $LINUX_ARCH == "powerpc" ]] && [[ $LINUX_ARCH == "powerpc64" ]] && [[ $LINUX_ARCH == "sparc" ]] && [[ $LINUX_ARCH == "aarch64" ]] && [[ $LINUX_ARCH == "s390" ]] && [[ $LINUX_ARCH == "hppa*" ]] && [[ $LINUX_ARCH == "alpha*" ]]; then
if [ "$LINUX_ARCH" != "x86_64" ] && [ "$LINUX_ARCH" != "i386" ] && [ "$LINUX_ARCH" != "i486" ] && [ "$LINUX_ARCH" != "amd64" ] && [ "$LINUX_ARCH" != "x86" ] && [ "$LINUX_ARCH" != "powerpc" ] && [ "$LINUX_ARCH" != "powerpc64" ] && [ "$LINUX_ARCH" != "sparc" ] && [ "$LINUX_ARCH" != "aarch64" ] && [ "$LINUX_ARCH" != "s390" ] && [ "$LINUX_ARCH" != "hppa*" ] && [ "$LINUX_ARCH" != "alpha*" ]; then
show_progress_error "Sorry, architecture is not supported. Let's see if the repos has this"
apt-get -y --force-yes install libx264-dev
else
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
./configure --enable-static
make
checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
--fstrans=no --default
fi
show_progress " Installing fdk-aac"
################################### fdk-aac
cd ~/src-build/build-ffmpeg
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
autoreconf -fiv
./configure --disable-shared
make
checkinstall --pkgname=fdk-aac --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
show_progress " Installing libvpx"
################################### libvpx
cd ~/src-build/build-ffmpeg
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --disable-examples --disable-unit-tests
make
checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
show_progress " Installing opus"
################################### opus
cd ~/src-build/build-ffmpeg
git clone --depth 1 git://git.xiph.org/opus.git
cd opus
./autogen.sh
./configure --disable-shared
make
checkinstall --pkgname=libopus --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
#show_progress " Installing libmp3lame"
################################### libmp3lame
# doesn't install in ubuntu, ends up with an error
#apt-get -y --force-yes install nasm
#cd ~/src-build/build-ffmpeg
#wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#tar xzvf lame-3.99.5.tar.gz
#cd lame-3.99.5
#./configure --enable-nasm --disable-shared
#make
#checkinstall --fstrans=no --pkgname=lame-ffmpeg --pkgversion="3.98.4" --backup=no --default --deldoc=yes
show_progress " Installing librtmp"
#################################### librtmp
# Let's install what's needed...
if [ "$LINUX_ARCH" != "x86_64" ] && [ "$LINUX_ARCH" != "i386" ] && [ "$LINUX_ARCH" != "i486" ] && [ "$LINUX_ARCH" != "amd64" ] && [ "$LINUX_ARCH" != "x86" ]; then
# Systems such as ppc64 does have trouble compiling this...
show_progress_error "Warning! This will affect the total time since instead of compiling, I will be using the librtmp-dev from the repos"
apt-get install librtmp-dev
else
cd ~/src-build/build-ffmpeg
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump
make SYS=posix
checkinstall --pkgname=rtmpdump --pkgversion="2:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
export LD_LIBRARY_PATH=/usr/local/lib/
fi
show_progress "Now... Using all above, compiling FFMpeg"
################################### Finally, ffmpeg
cd ~/src-build/build-ffmpeg
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-nonfree \
--enable-libfaac \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-postproc \
--enable-version3 \
--enable-librtmp \
--enable-libxvid \
--enable-libgsm \
--enable-zlib \
--enable-swscale \
--enable-pthreads
make
checkinstall --pkgname=ffmpeg --pkgversion="7:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
hash -r
################################################################### END OF FFPMEG
###################################################################
###################################################################
show_progress "Installing ImageMagick"
################################################################### IMAGEMAGICK
#show_progress " Installing jpegsrc"
######################################### JPEGSRC
#cd ~/src-build/
#wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
#tar -xzvf jpegsrc.v9a.tar.gz
#cd jpeg-9a/
#./configure --enable-static --enable-shared
#make
#make install
######################################### END OF JPEGSRC
######################################### LINUNWIND & GPERFTOOLS
show_progress " Installing libunwind"
mkdir -p ~/src-build/gperftools
cd ~/src-build/gperftools
#wget -c http://ftp.twaren.net/Unix/NonGNU/libunwind/libunwind-1.1.tar.gz
#tar zxvf libunwind-1.1.tar.gz
git clone git://git.sv.gnu.org/libunwind.git
cd libunwind
./autogen.sh
./configure CFLAGS=-U_FORTIFY_SOURCE
make
make install
show_progress " Installing gperftools"
cd ~/src-build/gperftools
git clone https://code.google.com/p/gperftools-git/
cd gperftools-git
./autogen.sh
./configure --prefix=/usr/local/gperftools --enable-shared --enable-frame-pointers
make
make install
cp -r /usr/local/gperftools/lib/* /usr/local/lib/
if [ ! -d /tmp/tcmalloc ]; then
mkdir /tmp/tcmalloc
chmod 0777 /tmp/tcmalloc/
chown -R www-data:www-data /tmp/tcmalloc
else
chmod 0777 /tmp/tcmalloc/
chown -R www-data:www-data /tmp/tcmalloc
fi
show_progress " Installing apt-get additions for gperftools"
apt-get -y --force-yes install google-perftools libgoogle-perftools-dev
export PPROF_PATH=/usr/local/bin/pprof
#########################################
show_progress " Installing webp"
cd ~/src-build/
#wget http://downloads.webmproject.org/releases/webp/libwebp-0.4.2.tar.gz
#tar -xvzf libwebp-0.4.2.tar.gz
git clone https://github.com/webmproject/libwebp.git
cd libwebp
./autogen.sh
./configure
make
make install
show_progress "Compile ImageMagick, shall we?"
######################################### ImageMagick
cd ~/src-build/
wget -c http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -zxvf ImageMagick.tar.gz
cd ImageMagick*
./configure --prefix=/usr/local/ImageMagick/ \
--sysconfdir=/etc \
--with-modules \
--with-gslib \
--with-wmf \
--with-webp \
--with-gslib \
--with-perl=/usr/bin/perl \
--disable-static
make
#checkinstall --fstrans=no --install=no -y
make install
#cd ~/src-build/
#rm -rf ImageMagick-*
#########################################
show_progress "Now, let's start Nginx installation"
show_progress " Installing OpenSSL"
######################################### OpenSSL
cd /root/ngx-build/
git clone https://github.com/openssl/openssl.git
show_progress " Installing ngx_pagespeed"
######################################### ngx_pagespeed
cd /root/ngx-build/
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.9.32.3-beta.zip
unzip release-1.9.32.3-beta.zip
cd ngx_pagespeed-release-1.9.32.3-beta/
show_progress " Installing psol for ngx_pagespeed"
# Can change it with the https one. But it is slower.
wget http://dl.google.com/dl/page-speed/psol/1.9.32.3.tar.gz
tar -xzvf 1.9.32.3.tar.gz # extracts to psol/
# Timer reminder
DIFFX=$(( $(date +%s) - $START ))
echo Up till now it took $(($DIFFX / 60 )) minutes and $(($DIFFX % 60 )) seconds... > time.tmp
show_progress_error2 "$(cat time.tmp)"
######################################### Necessary modules from GitHub
show_progress "Git cloning modules"
#cd /root/ngx-build/
#git clone https://github.com/openresty/headers-more-nginx-module.git
#cd /root/ngx-build/
#git clone https://github.com/openresty/echo-nginx-module.git
cd /root/ngx-build/
git clone https://github.com/nbs-system/naxsi.git
cd /root/ngx-build/
git clone https://github.com/arut/nginx-dav-ext-module.git
cd /root/ngx-build/
git clone https://github.com/slact/nginx_http_push_module.git
cd /root/ngx-build/
git clone https://github.com/arut/nginx-rtmp-module.git
cd /root/ngx-build/
git clone https://github.com/arut/nginx-dlna-module.git
cd /root/ngx-build/
git clone https://github.com/tg123/websockify-nginx-module.git
cd /root/ngx-build/
git clone https://github.com/masterzen/nginx-upload-progress-module.git
cd /root/ngx-build/
git clone https://github.com/gnosek/nginx-upstream-fair.git
cd /root/ngx-build/
git clone https://github.com/wandenberg/nginx-video-thumbextractor-module.git
cd /root/ngx-build/
git clone https://github.com/FRiCKLE/ngx_cache_purge.git
cd /root/ngx-build/
git clone https://github.com/aperezdc/ngx-fancyindex.git
show_progress "Last... Getting, compiling nginx, doing some tweaks etc. Be patient, will you!"
mkdir ~/nginx-package/
cd ~/nginx-package/
if [ "$LINUX_ARCH" != "x86_64" ] && [ "$LINUX_ARCH" != "i386" ] && [ "$LINUX_ARCH" != "i486" ] && [ "$LINUX_ARCH" != "amd64" ] && [ "$LINUX_ARCH" != "x86" ]; then
#Ubuntu
show_progress_error "Warning, Openresty can not be compiled with pcre-jit module on PowerPC, replacing it with Nginx!"
show_progress_error "Also ngx_pagespeed won't compile on ppc architecture either. So skipping it..."
wget http://nginx.org/download/nginx-1.7.9.tar.gz
tar -xvzf nginx-1.7.9.tar.gz
cd nginx-1.7.9
./configure \
--prefix=/usr/local/nginx/ \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client \
--http-proxy-temp-path=/var/cache/nginx/proxy \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi \
--http-scgi-temp-path=/var/cache/nginx/scgi \
--add-module=/root/ngx-build/naxsi/naxsi_src \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-ipv6 \
--with-debug \
--with-sha1=/usr/include/openssl \
--with-md5=/usr/include/openssl \
--user=www-data \
--group=www-data \
--with-http_stub_status_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_stub_status_module \
--with-http_secure_link_module \
--with-http_sub_module \
--with-http_addition_module \
--with-http_geoip_module \
--with-http_perl_module \
--with-http_random_index_module \
--with-http_stub_status_module \
--with-google_perftools_module \
--with-http_gunzip_module \
--with-http_spdy_module \
--with-file-aio \
--with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' \
--with-openssl=/root/ngx-build/openssl \
--add-module=/root/ngx-build/nginx-upload-progress-module \
--add-module=/root/ngx-build/nginx_http_push_module \
--add-module=/root/ngx-build/ngx-fancyindex \
--add-module=/root/ngx-build/nginx-dav-ext-module \
--add-module=/root/ngx-build/ngx_cache_purge \
--add-module=/root/ngx-build/nginx-dlna-module \
--add-module=/root/ngx-build/nginx-rtmp-module \
--add-module=/root/ngx-build/websockify-nginx-module \
--add-module=/root/ngx-build/nginx-upstream-fair
else
wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
tar -xvzf ngx_openresty-1.7.7.2.tar.gz
cd ngx_openresty-1.7.7.2
./configure \
--prefix=/usr/local/nginx/ \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client \
--http-proxy-temp-path=/var/cache/nginx/proxy \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi \
--http-scgi-temp-path=/var/cache/nginx/scgi \
--add-module=/root/ngx-build/naxsi/naxsi_src \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-ipv6 \
--with-debug \
--with-pcre-jit \
--with-sha1=/usr/include/openssl \
--with-md5=/usr/include/openssl \
--user=www-data \
--group=www-data \
--with-http_stub_status_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_stub_status_module \
--with-http_secure_link_module \
--with-http_sub_module \
--with-http_addition_module \
--with-http_geoip_module \
--with-http_perl_module \
--with-http_random_index_module \
--with-http_stub_status_module \
--with-google_perftools_module \
--with-http_gunzip_module \
--with-http_spdy_module \
--with-file-aio \
--with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' \
--with-openssl=/root/ngx-build/openssl \
--add-module=/root/ngx-build/nginx-upload-progress-module \
--add-module=/root/ngx-build/ngx_pagespeed-release-1.9.32.3-beta \
--add-module=/root/ngx-build/nginx_http_push_module \
--add-module=/root/ngx-build/ngx-fancyindex \
--add-module=/root/ngx-build/nginx-dav-ext-module \
--add-module=/root/ngx-build/ngx_cache_purge \
--add-module=/root/ngx-build/nginx-dlna-module \
--add-module=/root/ngx-build/nginx-rtmp-module \
--add-module=/root/ngx-build/websockify-nginx-module \
--add-module=/root/ngx-build/nginx-upstream-fair
fi
make
#make install
# mkdir -p /var/cache/nginx/{client,scgi,uwsgi,fastcgi,proxy}
# Create and change ownership some folders
for dir in /var/cache/nginx/ /var/cache/nginx/client /var/cache/nginx/scgi /var/cache/nginx/uwsgi /var/cache/nginx/fastcgi /var/cache/nginx/proxy /var/ngx_pagespeed_cache /var/log/nginx /var/log/pagespeed /usr/local/nginx/nginx/logs /var/ngx_pagespeed_cache /var/log/pagespeed /etc/nginx/sites-available sites-enabled
do
if [ ! -d $dir ]; then
mkdir -p $dir
chown -R www-data:www-data $dir
else
chown -R www-data:www-data $dir
fi
done
# Now let's build nginx deb file.
# Warning, it's not set to auto-install as of now.
show_progress "Installing Nginx"
checkinstall --fstrans=no --pkgname=nginx --install=yes -y
show_progress "Creating Nginx startup script"
######################################### Add nginx to /etc/init.d for
wget -O nginx.init https://raw.githubusercontent.com/Fleshgrinder/nginx-sysvinit-script/master/nginx
mv nginx.init /etc/init.d/nginx
chmod +x /etc/init.d/nginx
#Add it to system startup
update-rc.d -f nginx defaults
#alternately
#chkconfig —add nginx
#chkconfig nginx on
# Let's make sure naxsi library is in nginx directory
cp /root/ngx-build/naxsi/naxsi_config/naxsi_core.rules /etc/nginx
cd ~/
git clone https://github.com/nomadturk/nginx-conf.git
cd nginx-conf
mv -f * /etc/nginx/
git clone https://github.com/h5bp/server-configs-nginx.git
cd server-configs-nginx
mv -f h5bp mime.types doc/ /etc/nginx
cd ~/
rm -r -f ~/nginx-conf
show_progress "Uh oh... We forgot installing mysql. So... MariaDB it is!"
cd ~/
## MariaDB
if [ "$LINUX_ARCH" != "x86_64" ] && [ "$LINUX_ARCH" != "i386" ] && [ "$LINUX_ARCH" != "i486" ] && [ "$LINUX_ARCH" != "amd64" ] && [ "$LINUX_ARCH" != "x86" ]; then
show_progress_error "Can install MariaDB to this system using external repos. Let's try if your own repos have anything to offer"
apt-get -y --force-yes install mariadb-server
# End timer, we do not want mysql password screen to mess up with our resulting time now, do we?
END=$(date +%s)
echo $END >> ~/Time.Vars
else
apt-get -y --force-yes install python-software-properties
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
if [ "$LINUX_DISTRO" == "Debian" ]; then
#Debian
show_progress "Adding MariaDB Wheezy Repository"
add-apt-repository 'deb http://ams2.mirrors.digitalocean.com/mariadb/repo/5.5/debian wheezy main'
apt-get update
elif [ "$LINUX_DISTRO" == "Ubuntu" ]; then
#Ubuntu
show_progress "Adding MariaDB Trusty Repository"
add-apt-repository 'deb http://ams2.mirrors.digitalocean.com/mariadb/repo/5.5/ubuntu trusty main'
apt-get update
fi
# End timer, we do not want mysql password screen to mess up with our resulting time now, do we?
END=$(date +%s)
echo $END >> ~/Time.Vars
apt-get -y --force-yes install mariadb-server
fi
# mariadb-client mariadb-common
# Start timer again.
START2=$(date +%s)
echo $START2 >> ~/Time.Vars
## DotDeb Php 5.5 repository for Debian
if [ "$LINUX_DISTRO" == "Debian" ]; then
#Debian
show_progress "Adding DotDeb Php 5.5 Repository"
add-apt-repository 'deb http://packages.dotdeb.org wheezy all'
add-apt-repository 'deb http://packages.dotdeb.org wheezy-php55 all'
wget http://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg
fi
apt-get update
apt-get -y --force-yes install php5-fpm php5-mysql php5-xcache memcached php5-memcache php5-memcached
apt-get -y --force-yes install php5-mcrypt php5-cli php5-curl php5-gd php5-json php5-sqlite php5-pspell php5-readline php5-recode php5-xmlrpc php5-xsl php5-intl php5-imagick php5-tidy
show_progress "Time for a bit of tweaks"
if [ -f /etc/php5/fpm/php.ini ]; then
sed -i "s/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini
fi
if [ -f /etc/php5/fpm/pool.d/www.conf ]; then
sed -i "s/^;listen.owner = www-data/listen.owner = www-data/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^;listen.group = www-data/listen.group = www-data/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^;listen.mode = 0660/listen.mode = 0660/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^;listen.backlog = 128/listen.backlog = 65536/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^;listen.backlog = 65535/listen.backlog = 65536/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^listen=.*$/listen = 127.0.0.1:9000/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/^listen =.*$/listen = 127.0.0.1:9000/" /etc/php5/fpm/pool.d/www.conf
/etc/init.d/php5-fpm stop
/etc/init.d/php5-fpm start
fi
if [ -f /etc/nginx/h5bp/location/expires.conf ]; then
sed -i "s/^ access_log logs\/static.log/ access_log \/var\/log\/nginx\/static.log/" /etc/nginx/h5bp/location/expires.conf
fi
if [ ! -d /var/www ]; then
mkdir -p /var/www
if [ -d /usr/local/nginx/nginx/html/ ]; then
show_progress "Creating /var/www"
cp /usr/local/nginx/nginx/html/* /var/www/
elif [ -d /usr/local/nginx/html ]; then
show_progress "Creating /var/www"
cp /usr/local/nginx/html/* /var/www/
fi
fi
show_progress "Starting Nginx"
service nginx start
show_progress "Add nginx to logrotate"
######################################### Let's add nginx to logrotate and do an update
cd~/
echo "/var/log/nginx/*.log {" >> nginx.logrotate
echo " daily" >> nginx.logrotate
echo " missingok" >> nginx.logrotate
echo " rotate 52" >> nginx.logrotate
echo " compress" >> nginx.logrotate
echo " delaycompress" >> nginx.logrotate
echo " notifempty" >> nginx.logrotate
echo " create 640 www-data adm" >> nginx.logrotate
echo " sharedscripts" >> nginx.logrotate
echo " postrotate" >> nginx.logrotate
echo " [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`" >> nginx.logrotate
echo " endscript" >> nginx.logrotate
echo "}" > nginx.logrotate
if [ -f /etc/logrotate.d/nginx ]; then
rm /etc/logrotate.d/nginx
fi
mv nginx.logrotate /etc/logrotate.d/nginx
chmod 0644 /etc/logrotate.d/nginx
logrotate -f -v /etc/logrotate.d/nginx
#########################################
show_progress "Done and done... Enjoy it. All is ready to go."
END2=$(date +%s)
echo $END2>> ~/Time.Vars
DIFF1=$(( END - START ))
DIFF2=$(( END2 - START2 ))
DIFF=$(( DIFF1 + DIFF2 ))
echo Hurray! In mere $(($DIFF / 60 )) minutes and $(($DIFF % 60 )) seconds all is finished! Congrats dude... >>Time.Output
show_progress_info "$(cat Time.Output)"
show_progress_info "This is of course excluding the time spent at MariaDB Password input page."
#echo "Hurray! In mere "$(($DIFF / 3600 ))"" hours "$(($DIFF / 60 ))" minutes and "$(($DIFF % 60 ))" seconds all is finished! Congrats dude..." >>Time.Output
read -s -n 1 any_key | show_progress_info "Press a key to exit now..." && wait
wget -O VirtMin.sh http://software.virtualmin.com/gpl/scripts/install.sh
sed -i '/debdeps=/s/ mysql-/ mariadb-/g' VirtMin.sh
chmod +x VirtMin.sh
bash -c "bash VirtMin.sh"
/etc/init.d/apache2 stop
update-rc.d apache2 remove
apt-get -y --force-yes install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
apt-mark hold ffmpeg
apt-mark hold nginx
apt-mark hold mysql-common