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
|
#!/bin/bash
#by 2015-7-25--lijq
#directiof for use:源码包和脚本在同一目录且在root目录下的文件里
DIR=
/mnt/soft/
SCRIPT_DIR=
/root/autolamp
if
[ $UID -
ne
0 ];
then
echo
-e
"\033[32monly for root to install this LAMP\033[0m"
exit
3
fi
echo
-e
"\033[32mcreate soft dowload dir....\033[0m"
if
[ ! -d $DIR ];
then
mkdir
-p $DIR;
fi
echo
-e
"\033[32minstal some dependent packages,please wait for .... \033\0m"
yum
install
gcc gcc-c++
make
cmake ncurses-devel bison perl lrzsz epel-release pcre-devel openssl-devel -y;
yum
install
wget unzip libxml2-devel libmcrypt-devel
bzip2
-devel libxml2-devel openssl-devel
bzip2
bzip2
-devel -y
;
APR_FILE=apr-1.5.2.
tar
.gz
APR=`
echo
$APR_FILE |
sed
's/\.tar\.gz//g'
`
APR_UTILS=apr-util-1.5.2.
tar
.gz
APR_UTIL=`
echo
$APR_UTILS |
sed
's/\.tar\.gz//g'
`
APACHE_FILE=httpd-2.4.16.
tar
.gz
APACHE=`
echo
$APACHE_FILE |
sed
's/\.tar\.gz//g'
`
APR_DIR=
/usr/local/apr/
APRUTIL_DIR=
/usr/local/apr-util/
APACHE_DIR=
/usr/local/apache/
function
httpd_install()
{
if
[ -f $APR_FILE -o -f $APR_UTILS -o -f $APACHE_FILE ];
then
cp
$APR_FILE $APR_UTILS $APACHE_FILE $DIR -a
else
cd
$DIR;
wget -c http:
//archive
.apache.org
/dist/apr/
$APR_FILE;
wget -c http:
//archive
.apache.org
/dist/apr/
$APR_UTILS;
wget -c http:
//www
.apache.org
/dist/httpd/
$APACHE_FILE;
fi
cd
$DIR
tar
xzvf $APR_FILE;
cd
$APR;.
/configure
--prefix=$APR_DIR &&
make
&&
make
install
;
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mThis apr is install successfully...\033[0m"
else
echo
-e
"\033[32mThis apr is install failed,please check....\033[0m"
exit
fi
cd
$DIR;
tar
xzvf $APR_UTILS;
cd
$APR_UTIL;
.
/configure
--prefix=$APRUTIL_DIR --with-apr=$APR_DIR &&
make
&&
make
install
;
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mThis apr-util is install successfully....\033[0m"
else
echo
-e
"\033[32mThis arp in install failed, please check....\033[0m"
exit
fi
cd
$DIR;
tar
xzvf $APACHE_FILE;
cd
$APACHE;
.
/configure
--prefix=$APACHE_DIR --
enable
-so --
enable
-ssl --
enable
-cgi--
enable
-rewrite --with-zlib --with-pcre -
-with-apr=$APR_DIR --with-apr-util=$APRUTIL_DIR --
enable
-modules=most --
enable
-mpms-shared=all --with-mpm=event &&
make
&
&
make
install
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mThe apache is install successful..\033[0m"
$APACHE_DIR
/bin/apachectl
restart;
else
echo
-e
"\033[32mTHE apache is install failed,please check....\033[0m"
exit
fi
}
sleep
3
MYSQL_FILE=
'mysql-5.5.44.tar.gz'
MYSQL=`
echo
$MYSQL_FILE |
sed
's/\.tar\.gz//g'
`
DATADIR=
/data/mysql3306
BASEDIR=
/data/app/mysql3306
MYSQL_STATUS=`
ps
-ef |
grep
mysqld_safe |
awk
'NR==1 {print $9}'
|
sed
's#\/data\/app\/mysql3306\/bin\/##g'
`
function
mysql_install()
{
cd
$SCRIPT_DIR ;
if
[ -f
"$MYSQL_FILE"
];
then
cp
${MYSQL_FILE} $DIR -a ;
sleep
2
else
cd
$DIR;
wget -c http:
//download
.softagency.net
/MySQL/Downloads/MySQL-5
.5/$MYSQL_FILE;
fi
cd
$DIR;
tar
xzvf $MYSQL_FILE;
cd
$MYSQL;
mkdir
-p {$DATADIR,$DATADIR};
cmake \-DCMAKE_INSTALL_PREFIX=$BASEDIR \-DMYSQL_DATADIR=$DATADIR \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE
_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-D
WITH_PARTITION_STORAGE_ENGINE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWIT
H_DEBUG=0 \-DMYSQL_USER=mysql \-DMYSQL_UNIX_ADDR=$DATADIR
/mysql3306
.sock &&
make
&&
make
install
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mthe mysql is install successful..\033[0m"
else
echo
-e
"\033[32mThis mysql is install failed.....\033[0m"
exit
2
fi
useradd
mysql;
chown
-R mysql.mysql $DATADIR;
chown
-R mysql:mysql $BASEDIR;
cp
-a support-files
/my-large
.cnf $DATADIR
/my
.cnf;
chown
-R mysql.mysql $DATADIR
/my
.cnf;
cp
-a $BASEDIR
/support-files/mysql
.server
/etc/init
.d
/mysqld
;
# sed -i '/mysql3306/i datadir = /data/mysql3306\nbasedir = /data/app/mysql3306' /data/mysql3306/my.cnf;
sed
-i
"26a\datadir = $DATADIR\nbasedir = $BASEDIR"
$DATADIR
/my
.cnf;
cd
$BASEDIR;.
/scripts/mysql_install_db
--basedir=$BASEDIR --datadir=$DATADIR --user=mysql;
echo
"export PATH="
\$PATH
":${BASEDIR}/bin/"
>>
/root/
.bash_profile &&
source
/root/
.bash_profile &&
/etc/init
.d
/mysqld
res
tart;pkill mysql;
/etc/init
.d
/mysqld
start;
/etc/init
.d
/mysqld
restart;
sleep
5
if
[ ${MYSQL_STATUS} =
'mysqld_safe'
];
then
echo
-e
"\033[32mThe Mysql was installed successfully....\033[0m"
else
echo
-e
"\033[31mThe Mysql is installed failed,Please check...\033[0m"
exit
fi
sleep
3
}
PHP_FILES=php-5.4.42.
tar
.bz2
PHP=`
echo
$PHP_FILES |
sed
's/\.tar\.bz2//g'
`
PHP_DIR=
/usr/local/php
function
php_install()
{
cd
$SCRIPT_DIR;
if
[ -f $PHP_FILES ];
then
cp
$PHP_FILES $DIR -a ;
else
cd
$DIR;
wget http:
//mirrors
.sohu.com
/php/
$PHP_FILES;
fi
cd
$DIR;
if
[ -d $BASEDIR ] ;
then
tar
xjvf $PHP_FILES ;
cd
$PHP;.
/configure
--prefix=$PHP_DIR --with-mysql=$BASEDIR --with-openssl --with-mysqli=$B
ASEDIR
/bin/mysql_config
--
enable
-mbstring --with-freetype-
dir
--with-jpeg-
dir
--with-png-
dir
--with-zlib --with-libxml-di
r=
/usr
--
enable
-xml --
enable
-sockets --
enable
-fpm --with-mcrypt --with-bz2 --with-config-
file
-path=
/etc/php/php
.ini --wit
h-config-
file
-scan-
dir
=
/etc/php/php
.d/ --with-apxs2=${APACHE_DIR}bin
/apxs
&&
make
&&
make
install
else
echo
-e
"\033[32mplease install this mysql....\033[0m"
fi
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mthe php is install successful..\033[0m"
else
echo
"the php is install failed,,,,please quit"
exit
fi
}
IP=`
ifconfig
eth0 |
grep
Bcast |
awk
'{print $2}'
|
sed
's/addr://g'
`
function
php_apache()
{
echo
-e
"\033[32mIt will configure the Apache and PHP\033[0m"
cp
${APACHE_DIR}conf
/httpd
.conf ${APACHE_DIR}conf
/httpd
.conf.bak
echo
"Addtype application/x-httpd-php .php"
>> ${APACHE_DIR}conf
/httpd
.conf
sed
-i
's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g'
${APACHE_DIR}conf
/httpd
.conf
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mIt's successfully, Will test the PHP... \033[0m"
rm
-rf ${APACHE_DIR}htdocs/*;
cat
>${APACHE_DIR}htdocs
/index
.php <<EOF
<?php
phpinfo();
?>
EOF
if
[ $? -
eq
0 ];
then
#启动apache服务
${APACHE_DIR}bin
/apachectl
restart ;
${APACHE_DIR}bin
/apachectl
restart ;
echo
-e
"\033[32mYou can access http://${IP}/index.php\033[0m"
fi
else
echo
-e
"\033[31mThe PHP is installed failed,Please check...\033[0m"
exit
fi
}
Discuz_file=Discuz_X3.1_SC_UTF8.zip
Discuz=Discuz_X3.1_SC_UTF8
PASSWORD=123456
function
discuz_install()
{
cd
$SCRIPT_DIR;
if
[ -f $Discuz_file ];
then
cp
$Discuz_file $DIR -a ;
sleep
2
else
cd
$DIR;
wget -c http:
//download
.comsenz.com
/DiscuzX/3
.1/$Discuz_file;
fi
cd
$DIR;
rm
-rf ${APACHE_DIR}htdocs/* && unzip $Discuz_file -d ${APACHE_DIR}htdocs/ ;
cd
${APACHE_DIR}htdocs/ &&
mv
upload/* . &&
chmod
-R o+w data/ config/ uc_server/ uc_client/;
if
[ $? -
eq
0 ];
then
echo
-e
'\033[32mThis discuz is files configure ok....\033[0m'
#设置数据库密码和创建数据库
$BASEDIR
/bin/mysqladmin
-uroot password $PASSWORD &&
mysql -uroot -h 127.0.0.1 -p$PASSWORD -e
"create database discuz;"
&&
#授权discuz用户
mysql -uroot -h 127.0.0.1 -p$PASSWORD -e "grant all on *.* to discuz@
'${IP}'
identified by
'$PASSWORD'
;flush priv
ileges;"
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mThis discuz database configure is success.....\033[0m"
else
echo
-e
"\033[32mThis discuz database configure is failed..please check..\033[0m"
fi
#重启apache服务和mysql
${APACHE_DIR}bin
/apachectl
restart&&
/etc/init
.d
/mysqld
restart;
if
[ $? -
eq
0 ];
then
echo
-e
"\033[32mThe apache and Mysql Start Success!\033[0m"
else
echo
-e
"\033[31mThis discuz configure is failed..please check.\033[0m"
echo
-e
"\033[32mThis discuz is install success.......\033[32m"
fi
else
echo
-e
"\033[32mThe mysql and apache is failed....please check.\033[0m"
exit
2
fi
}
PS3=
"please select your install menu:"
select
i
in
"httpd"
"mysql"
"php"
"php+apache"
"discuz"
"quit"
"all_auto"
do
case
$i
in
httpd )
httpd_install
;;
mysql )
mysql_install
;;
php )
php_install
;;
php+apache )
php_apache
;;
discuz )
discuz_install
;;
all_auto )
httpd_install;
mysql_install;
php_install;
php_apache;
discuz_install
;;
quit )
exit
;;
* )
echo
"Usage: $0 {httpd|mysql|php|php+apache|discuz|all_auto|quit}"
esac
done
|
版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任
本文转自 Anonymous123 51CTO博客,原文链接:http://blog.51cto.com/woshitieren/1678525