-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
279 lines (233 loc) · 9.76 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
#!/bin/bash
####---- global variables ----begin####
export nginx_version=1.4.4
export httpd_version=2.2.29
export mysql_version=5.1.73
export php_version=5.3.29
export phpwind_version=8.7
export phpmyadmin_version=4.1.8
export vsftpd_version=2.3.2
export sphinx_version=0.9.9
export install_ftp_version=0.0.0
####---- global variables ----end####
web=nginx
install_log=/alidata/website-info.log
####---- version selection ----begin####
tmp=1
read -p "Please select the web of nginx/apache, input 1 or 2 : " tmp
if [ "$tmp" == "1" ];then
web=nginx
elif [ "$tmp" == "2" ];then
web=apache
fi
tmp=1
if echo $web |grep "nginx" > /dev/null;then
read -p "Please select the nginx version of 1.4.4, input 1: " tmp
if [ "$tmp" == "1" ];then
nginx_version=1.4.4
fi
else
read -p "Please select the apache version of 2.2.29/2.4.10, input 1 or 2 : " tmp
if [ "$tmp" == "1" ];then
httpd_version=2.2.29
elif [ "$tmp" == "2" ];then
httpd_version=2.4.10
fi
fi
tmp=1
read -p "Please select the php version of 5.3.29/5.4.23/5.5.7, input 1 or 2 or 3 : " tmp
if [ "$tmp" == "1" ];then
php_version=5.3.29
elif [ "$tmp" == "2" ];then
php_version=5.4.23
elif [ "$tmp" == "3" ];then
php_version=5.5.7
fi
tmp=1
read -p "Please select the mysql version of 5.1.73/5.5.40/5.6.21, input 1 or 2 or 3 : " tmp
if [ "$tmp" == "1" ];then
mysql_version=5.1.73
elif [ "$tmp" == "2" ];then
mysql_version=5.5.40
elif [ "$tmp" == "3" ];then
mysql_version=5.6.21
fi
echo ""
echo "You select the version :"
echo "web : $web"
if echo $web |grep "nginx" > /dev/null;then
echo "nginx : $nginx_version"
else
echo "apache : $httpd_version"
fi
echo "php : $php_version"
echo "mysql : $mysql_version"
read -p "Enter the y or Y to continue:" isY
if [ "${isY}" != "y" ] && [ "${isY}" != "Y" ];then
exit 1
fi
####---- version selection ----end####
####---- Clean up the environment ----begin####
echo "will be installed, wait ..."
./uninstall.sh in &> /dev/null
####---- Clean up the environment ----end####
if echo $web|grep "nginx" > /dev/null;then
web_dir=nginx-${nginx_version}
else
web_dir=httpd-${httpd_version}
fi
php_dir=php-${php_version}
if [ `uname -m` == "x86_64" ];then
machine=x86_64
else
machine=i686
fi
####---- global variables ----begin####
export web
export web_dir
export php_dir
export mysql_dir=mysql-${mysql_version}
export vsftpd_dir=vsftpd-${vsftpd_version}
export sphinx_dir=sphinx-${sphinx_version}
####---- global variables ----end####
ifredhat=$(cat /proc/version | grep redhat)
ifcentos=$(cat /proc/version | grep centos)
ifubuntu=$(cat /proc/version | grep ubuntu)
ifdebian=$(cat /proc/version | grep -i debian)
####---- install dependencies ----begin####
if [ "$ifcentos" != "" ] || [ "$machine" == "i686" ];then
rpm -e httpd-2.2.3-31.el5.centos gnome-user-share &> /dev/null
fi
\cp /etc/rc.local /etc/rc.local.bak
if [ "$ifredhat" != "" ];then
rpm -e --allmatches mysql MySQL-python perl-DBD-MySQL dovecot exim qt-MySQL perl-DBD-MySQL dovecot qt-MySQL mysql-server mysql-connector-odbc php-mysql mysql-bench libdbi-dbd-mysql mysql-devel-5.0.77-3.el5 httpd php mod_auth_mysql mailman squirrelmail php-pdo php-common php-mbstring php-cli &> /dev/null
fi
if [ "$ifredhat" != "" ];then
\mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak &> /dev/null
\cp ./res/rhel-debuginfo.repo /etc/yum.repos.d/
yum makecache
yum -y remove mysql MySQL-python perl-DBD-MySQL dovecot exim qt-MySQL perl-DBD-MySQL dovecot qt-MySQL mysql-server mysql-connector-odbc php-mysql mysql-bench libdbi-dbd-mysql mysql-devel-5.0.77-3.el5 httpd php mod_auth_mysql mailman squirrelmail php-pdo php-common php-mbstring php-cli &> /dev/null
yum -y install gcc gcc-c++ gcc-g77 make libtool autoconf patch unzip automake fiex* libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl libmcrypt libmcrypt-devel libpng libpng-devel libjpeg-devel openssl openssl-devel curl curl-devel libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl autoconf automake libaio*
iptables -F
elif [ "$ifcentos" != "" ];then
if grep 5.10 /etc/issus ;then
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
fi
sed -i 's/^exclude/#exclude/' /etc/yum.conf
yum makecache
yum -y remove mysql MySQL-python perl-DBD-MySQL dovecot exim qt-MySQL perl-DBD-MySQL dovecot qt-MySQL mysql-server mysql-connector-odbc php-mysql mysql-bench libdbi-dbd-mysql mysql-devel-5.0.77-3.el5 httpd php mod_auth_mysql mailman squirrelmail php-pdo php-common php-mbstring php-cli &> /dev/null
yum -y install gcc gcc-c++ gcc-g77 make libtool autoconf patch unzip automake libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl libmcrypt libmcrypt-devel libpng libpng-devel libjpeg-devel openssl openssl-devel curl curl-devel libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl autoconf automake libaio*
iptables -F
elif [ "$ifubuntu" != "" ];then
apt-get -y update
\mv /etc/apache2 /etc/apache2.bak &> /dev/null
\mv /etc/nginx /etc/nginx.bak &> /dev/null
\mv /etc/php5 /etc/php5.bak &> /dev/null
\mv /etc/mysql /etc/mysql.bak &> /dev/null
apt-get -y autoremove apache2 nginx php5 mysql-server &> /dev/null
apt-get -y install unzip build-essential libncurses5-dev libfreetype6-dev libxml2-dev libssl-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libpcre3-dev autoconf libperl-dev libtool libaio*
iptables -F
elif [ "$ifdebian" != "" ];then
apt-get -y update
\mv /etc/apache2 /etc/apache2.bak &> /dev/null
\mv /etc/nginx /etc/nginx.bak &> /dev/null
\mv /etc/php5 /etc/php5.bak &> /dev/null
\mv /etc/mysql /etc/mysql.bak &> /dev/null
apt-get -y autoremove apache2 nginx php5 mysql-server &> /dev/null
apt-get -y install unzip psmisc build-essential libncurses5-dev libfreetype6-dev libxml2-dev libssl-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libpcre3-dev autoconf libperl-dev libtool libaio*
iptables -F
fi
####---- install dependencies ----end####
####---- install software ----begin####
rm -f tmp.log
echo tmp.log
./env/install_set_sysctl.sh
./env/install_set_ulimit.sh
if [ -e /dev/xvdb ];then
./env/install_disk.sh
fi
./env/install_dir.sh
echo "---------- make dir ok ----------" >> tmp.log
./env/install_env.sh
echo "---------- env ok ----------" >> tmp.log
./mysql/install_${mysql_dir}.sh
echo "---------- ${mysql_dir} ok ----------" >> tmp.log
if echo $web |grep "nginx" > /dev/null;then
./nginx/install_nginx-${nginx_version}.sh
echo "---------- ${web_dir} ok ----------" >> tmp.log
./php/install_nginx_php-${php_version}.sh
echo "---------- ${php_dir} ok ----------" >> tmp.log
else
./apache/install_httpd-${httpd_version}.sh
echo "---------- ${web_dir} ok ----------" >> tmp.log
./php/install_httpd_php-${php_version}.sh
echo "---------- ${php_dir} ok ----------" >> tmp.log
fi
./php/install_php_extension.sh
echo "---------- php extension ok ----------" >> tmp.log
./ftp/install_${vsftpd_dir}.sh
install_ftp_version=$(vsftpd -v 0> vsftpd_version && cat vsftpd_version |awk -F: '{print $2}'|awk '{print $2}' && rm -f vsftpd_version)
echo "---------- vsftpd-$install_ftp_version ok ----------" >> tmp.log
./res/install_soft.sh
echo "---------- phpwind-$phpwind_version ok ----------" >> tmp.log
echo "---------- phpmyadmin-$phpmyadmin_version ok ----------" >> tmp.log
echo "---------- web init ok ----------" >> tmp.log
####---- install software ----end####
####---- Start command is written to the rc.local ----begin####
if ! cat /etc/rc.local | grep "/etc/init.d/mysqld" > /dev/null;then
echo "/etc/init.d/mysqld start" >> /etc/rc.local
fi
if echo $web|grep "nginx" > /dev/null;then
if ! cat /etc/rc.local | grep "/etc/init.d/nginx" > /dev/null;then
echo "/etc/init.d/nginx start" >> /etc/rc.local
echo "/etc/init.d/php-fpm start" >> /etc/rc.local
fi
else
if ! cat /etc/rc.local | grep "/etc/init.d/httpd" > /dev/null;then
echo "/etc/init.d/httpd start" >> /etc/rc.local
fi
fi
if ! cat /etc/rc.local | grep "/etc/init.d/vsftpd" > /dev/null;then
echo "/etc/init.d/vsftpd start" >> /etc/rc.local
fi
####---- Start command is written to the rc.local ----end####
####---- centos yum configuration----begin####
if [ "$ifcentos" != "" ] && [ "$machine" == "x86_64" ];then
sed -i 's/^#exclude/exclude/' /etc/yum.conf
fi
if [ "$ifubuntu" != "" ] || [ "$ifdebian" != "" ];then
mkdir -p /var/lock
sed -i 's#exit 0#touch /var/lock/local#' /etc/rc.local
else
mkdir -p /var/lock/subsys/
fi
####---- centos yum configuration ----end####
####---- mysql password initialization ----begin####
echo "---------- rc init ok ----------" >> tmp.log
/alidata/server/php/bin/php -f ./res/init_mysql.php
echo "---------- mysql init ok ----------" >> tmp.log
####---- mysql password initialization ----end####
####---- Environment variable settings ----begin####
\cp /etc/profile /etc/profile.bak
if echo $web|grep "nginx" > /dev/null;then
echo 'export PATH=$PATH:/alidata/server/mysql/bin:/alidata/server/nginx/sbin:/alidata/server/php/sbin:/alidata/server/php/bin' >> /etc/profile
export PATH=$PATH:/alidata/server/mysql/bin:/alidata/server/nginx/sbin:/alidata/server/php/sbin:/alidata/server/php/bin
else
echo 'export PATH=$PATH:/alidata/server/mysql/bin:/alidata/server/httpd/bin:/alidata/server/php/sbin:/alidata/server/php/bin' >> /etc/profile
export PATH=$PATH:/alidata/server/mysql/bin:/alidata/server/httpd/bin:/alidata/server/php/sbin:/alidata/server/php/bin
fi
####---- Environment variable settings ----end####
####---- restart ----begin####
if echo $web|grep "nginx" > /dev/null;then
/etc/init.d/php-fpm restart > /dev/null
/etc/init.d/nginx restart > /dev/null
else
/etc/init.d/httpd restart > /dev/null
/etc/init.d/httpd start &> /dev/null
fi
/etc/init.d/vsftpd restart
####---- restart ----end####
####---- log ----begin####
\cp tmp.log $install_log
cat $install_log
####---- log ----end####