-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathubuntu16.04.sh
executable file
·132 lines (116 loc) · 3.87 KB
/
ubuntu16.04.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
#!/bin/bash
# LNMP Installer for Ubuntu 16.04 TLS
#
# @author Nick Tsai <[email protected]>
# @version 1.0.0
# @link https://github.com/yidas/server-installers
# Program commands check
for cmd in wget apt apt-get sudo service tar mv rm
do
if ! hash $cmd 2>/dev/null
then
echo "The required program '$cmd' is currently not installed. To run '$cmd' please ask your administrator to install the package '$cmd'"
exit 1
fi
done
# PHP
usePhp5=false;
# PHP default
echo "PHP: Do you want to additionally install PHP 5.6? [Y/n, empty as No]"
read yn
case $yn in
[Yy]* ) usePhp5=true;;
* )
esac
# PHP force asking
#while true; do
# echo "PHP: Default version is PHP 7, install old version PHP 5.6? [Y/n]"
# read yn
# case $yn in
# [Yy]* ) usePhp5=true; break;;
# [Nn]* ) break;;
# * ) echo "Please answer yes or no.";;
# esac
#done
# MySQL question
echo "MySQL: Do you want to install MySQL? [Y/n, empty as Yes]"
read yn
case $yn in
[Nn]* ) installMySQL=false;;
* )
installMySQL=true
echo "MySQL: Type the password for MySQL root, default is \`password\` followed by [ENTER]:"
read -s mysqlRootPassword
if [ ! $mysqlRootPassword ]; then
mysqlRootPassword='password'
fi
;;
esac
# PHPMyAdmin question
echo "PHPMyAdmin: Do you want to install PHPMyAdmin? [Y/n, empty as Yes]"
read yn
case $yn in
[Nn]* ) installPhpMyAdmin=false;;
* ) installPhpMyAdmin=true;;
esac
# PHPMyAdmin with Metro theme
if [ $installPhpMyAdmin = true ]; then
echo "PHPMyAdmin: Do you want to install Metro theme? [Y/n, empty as Yes]"
read yn
case $yn in
[Nn]* ) installPhpMyAdminTheme=false;;
* ) installPhpMyAdminTheme=true;;
esac
fi
# APT Source using IPv4
sudo apt-get update
# Nginx
sudo apt-get install nginx -y
# PHP
sudo apt-get install php-fpm php-mysql php-cli php-mcrypt php-curl php-mbstring php-imagick php-gd php-xml php-zip -y
sudo apt-get install php-memcached memcached -y
sudo phpenmod mcrypt
if [ $usePhp5 = true ]; then
# PHP 5.6
sudo apt-get install software-properties-common -y
sudo apt-get install python-software-properties -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php5.6-fpm php5.6-mysql php5.6-cli php5.6-mcrypt php5.6-curl php5.6-mbstring php5.6-imagick php5.6-gd php5.6-xml php5.6-zip -y
fi
# MySQL
if [ $installMySQL = true ]; then
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password ${mysqlRootPassword}"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password ${mysqlRootPassword}"
sudo apt-get install mysql-server -y
fi
# PHPMyAdmin
if [ $installPhpMyAdmin = true ]; then
# Configuration
version="4.8.2"
webPath="/var/www/html/"
#filename="phpMyAdmin-${version}-english"
filename="phpMyAdmin-${version}-all-languages"
fileUrl="https://files.phpmyadmin.net/phpMyAdmin/${version}/${filename}.tar.gz"
# Commands
sudo wget "${fileUrl}"
sudo tar -zxvf "${filename}.tar.gz" -C "${webPath}"
sudo rm -f "${filename}.tar.gz"
sudo mv "${webPath}${filename}" "${webPath}phpmyadmin"
# Nginx Default Site
configUrl='https://raw.githubusercontent.com/yidas/server-installers/master/LNMP/nginx-sites/default-php7.0-all'
sudo wget "${configUrl}" -O /etc/nginx/sites-available/default
# PHPMyAdmin theme
if [ $installPhpMyAdminTheme = true ]; then
# Configuration
file="metro-2.8.zip"
fileUrl="https://files.phpmyadmin.net/themes/metro/2.8/${file}"
# Commnads
pathTheme="${webPath}phpmyadmin/themes"
sudo wget "${fileUrl}" -P "${pathTheme}"
sudo apt install unzip -y
sudo unzip "${pathTheme}/${file}" -d "${pathTheme}/"
sudo rm "${pathTheme}/${file}"
fi
fi
sudo service nginx reload