lnmp 源码安装- 脚本执行
源码包版本:
nginx1.9
mysql5.6.4
php5.6
使用:
将lnmp.tar.gz 解压至 根目录下,进入/lnmp/install/目录下,执行install.sh脚本即可。选择性安装!
安装过程中会有些警告信息显示,不影响。
整合包地址:http://pan.baidu.com/s/1dFp7gqP
=======================代码=============================
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
|
#!/bin/bash
################################
#lnmp 安装
#jinchuang1025@163.com
# 需要将此包解压到根目录下面
################################
#装逼变量定义
color=`
echo
-e
"\033[36m!!请输入正确的编号!! \033[0m"
`
################################
while
true
do
echo
"**************-----------------****************
##! 需要将此安装压缩包解压至 / 目录下 !##
1: 更换yum源和安装相关包
2: 安装nginx
3: 安装mysql
4: 安装php
5: 调整nginx支持php
6:
exit
!
**************-----------------****************"
read
-p
"输入编号:"
n
case
$n
in
#*********** 更换yum源、安装需要的相关的包 **********#
1)
#iptables 和 selinux
service iptables stop >
/dev/null
sed
-i
's/SELINUX=enforcing/SELINUX=disabled/g'
/etc/selinux/config
setenforce 0
#更换yum源|阿里云的源和epel的源#
cd
/etc/yum
.repos.d/
mv
/etc/yum
.repos.d
/CentOS-Base
.repo
/etc/yum
.repos.d
/CentOS-Base
.repo.bak
echo
"更换yum 源 ..."
wget -O
/etc/yum
.repos.d
/CentOS-Base
.repo http:
//mirrors
.aliyun.com
/repo/Centos-6
.repo 2>&1 >
/dev/null
wget -O
/etc/yum
.repos.d
/epel
.repo http:
//mirrors
.aliyun.com
/repo/epel-6
.repo 2>&1 >
/dev/null
#yum安装相关依赖包#
echo
"安装需要相关的包 ..."
yum -y
install
vim wget lfzsz ntp
tar
make
openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ gcc-gfortran libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake
screen
sysstat compat-libstdc++-33 libtool flex bison
file
libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel glib2 glib2-devel
bzip2
bzip2
-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap
lsof
libmcrypt-devel mcytpt mhash libxslt-devel libcurl-devel 2>&1 >
/dev/null
echo
"包安装完成"
;;
#*********** 安装nginx **********#
2)
#解压需要的源码包#
cd
/lnmp/source
tar
-zxf nginx-1.9.8.
tar
.gz
tar
-zxf pcre-8.35.
tar
.gz
tar
-zxf openssl-1.0.2h.
tar
.gz
tar
-zxf zlib-1.2.8.
tar
.gz
#nginx 安装#
mkdir
/var/nginx
useradd
nginx -M -s
/sbin/nologin
#install nginx
cd
nginx-1.9.8
echo
"nginx configure 中 ..."
.
/configure
\
--prefix=
/lnmp/lnmp/nginx
\
--lock-path=
/var/nginx/nginx
.lock \
--user=nginx \
--group=nginx \
--http-client-body-temp-path=
/var/nginx/client/
\
--http-proxy-temp-path=
/var/nginx/proxy/
\
--http-fastcgi-temp-path=
/var/nginx/fcgi/
\
--http-uwsgi-temp-path=
/var/nginx/uwsgi
\
--http-scgi-temp-path=
/var/nginx/scgi
\
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-
file
-aio \
--with-http_image_filter_module \
--with-http_realip_module \
--with-pcre=
/lnmp/source/pcre-8
.35 \
--with-stream \
--with-openssl=
/lnmp/source/openssl-1
.0.2h \
--with-zlib=
/lnmp/source/zlib-1
.2.8 2>&1 >
/dev/null
echo
"nginx configure 完成"
echo
"make && make install 中 ..."
make
2>&1 >
/dev/null
make
install
2>&1 >
/dev/null
echo
"nginx make install 完成"
echo
"copy 启动脚本 ..."
cp
/lnmp/server/nginx
/etc/init
.d
/nginx
chmod
+x
/etc/init
.d
/nginx
# start nginx server|获取服务状态码
echo
"启动 Nginx"
service nginx start
ip=`
ifconfig
eth0 |
awk
-F
"[:| ]+"
'/inet addr:/{print $4}'
`
str=`curl -I -m 10 http:
//
$ip -o
/dev/null
-s -w %{http_code}`
if
[ $? ==
"0"
]
then
echo
"nginx 服务启动成功,状态码:$str"
else
echo
"nginx 服务启动失败,状态码:$str"
fi
echo
"
#######################
程序目录:
/lnmp/lnmp/nginx
配置文件:
/lnmp/lnmp/nginx/conf/
"
sleep
5
;;
#*********** 安装mysql **********#
3)
#创建用户
useradd
mysql -M -s
/sbin/nologin
mkdir
-p
/var/log/mysql
#解压相关包
cd
/lnmp/source
tar
-xf cmake-3.4.3.
tar
.gz
tar
-xf mysql-5.6.4-m7.
tar
.gz
#install cmake
cd
/lnmp/source/cmake-3
.4.3
echo
"cmake configure ..."
.
/configure
2>&1 >
/dev/null
echo
"camke configure 完成"
echo
"gmake && gmake install ..."
gmake 2>&1 >
/dev/null
gmake
install
2>&1 >
/dev/null
echo
"cmake 安装完成"
#install mysql
cd
/lnmp/source/mysql-5
.6.4-m7
echo
"cmake mysql ..."
cmake \
-DCMAKE_INSTALL_PREFIX=
/lnmp/lnmp/mysql
\
-DMYSQL_DATADIR=
/lnmp/lnmp/mysql/data
\
-DSYSCONFDIR=
/etc
\
-DMYSQL_USER=mysql \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=
/lnmp/lnmp/mysql/mysql
.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_SSL=system 2>&1 >
/dev/null
echo
" cmake mysql 完成"
echo
" mysql make && make install ..."
make
2>&1 >
/dev/null
make
install
2>&1 >
/dev/null
echo
" mysql make install 完成"
echo
"copy mysql 配置文件 授权..."
mv
/etc/my
.cnf
/etc/my
.cnf.bak
cp
/lnmp/etc/my
.cnf
/etc/
chmod
+w
/lnmp/lnmp/mysql
chown
-R mysql:mysql
/lnmp/lnmp/mysql
#初始化mysql
echo
"初始化数据库 ..."
/lnmp/lnmp/mysql/scripts/mysql_install_db
--defaults-
file
=
/etc/my
.cnf --basedir=
/lnmp/lnmp/mysql
--datadir=
/lnmp/lnmp/mysql/data
--user=mysql 2>&1 >
/dev/null
cp
/lnmp/source/mysql-5
.6.4-m7
/support-files/mysql
.server
/etc/init
.d
/mysqld
chmod
+x
/etc/init
.d
/mysqld
#start mysql
echo
"启动 mysql"
service mysqld start
echo
"
############################
程序目录:
/lnmp/lnmp/mysql
配置文件:
/etc/my
.cnf"
sleep
5
;;
#*********** 安装php **********#
4)
#创建程序运行用户(nginx 安装过则不需要此步骤)
useradd
nginx -M -s
/sbin/nologin
# 解压包
cd
/lnmp/source
tar
-xf php-5.6.20.
tar
.gz
tar
-xf libiconv-1.14.
tar
.gz
# install libiconv
cd
libiconv-1.14
echo
"configure libiconv ..."
.
/configure
--prefix=
/lnmp/lnmp/libiconv
2>&1 >
/dev/null
echo
"configure libiconv 完成"
echo
"libiconv make && make install ..."
make
2>&1 >
/dev/null
make
install
2>&1 >
/dev/null
echo
"libiconv make && make install 完成"
# install php
cd
/lnmp/source/php-5
.6.20
echo
"configure php ..."
.
/configure
\
--prefix=
/lnmp/lnmp/php-5
.6.20 \
--with-config-
file
-path=
/lnmp/lnmp/php-5
.6.20
/etc
\
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-bz2 \
--with-curl \
--with-gd \
--with-mcrypt \
--with-openssl \
--with-mhash \
--with-jpeg-
dir
\
--with-png-
dir
\
--with-freetype-
dir
\
--with-iconv-
dir
=
/lnmp/lnmp/libiconv
\
--with-gettext \
--with-libxml-
dir
=
/lnmp/lnmp
\
--with-zlib \
--with-xsl \
--with-pdo-mysql=mysqlnd \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-libdir=lib64 \
--
enable
-dom \
--
enable
-xml \
--
enable
-fpm \
--
enable
-bcmath \
--
enable
-
ftp
\
--
enable
-sockets \
--disable-ipv6 \
--
enable
-mbregex \
--
enable
-mbstring \
--
enable
-calendar \
--
enable
-gd-native-ttf \
--
enable
-static 2>&1 >
/dev/null
echo
"configure php 完成"
echo
"php make && make install ..."
make
2>&1 >
/dev/null
make
install
2>&1 >
/dev/null
#安装后配置文件和启动改动
echo
"copy 文件,添加启动脚本..."
cp
php.ini-production
/lnmp/lnmp/php-5
.6.20
/etc/php
.ini
cp
/lnmp/lnmp/php-5
.6.20
/etc/php-fpm
.conf.default
/lnmp/lnmp/php-5
.6.20
/etc/php-fpm
.conf
mkdir
-p
/lnmp/lnmp/php-5
.6.20
/log
cp
/lnmp/server/php-fpm
/etc/init
.d/
chmod
+x
/etc/init
.d
/php-fpm
echo
"启动 php"
service php-fpm start
echo
"
#####################
程序目录:
/lnmp/lnmp/php-5
.6.20
php-fpm.conf
/php
.ini :
/lnmp/lnmp/php-5
.6.20
/etc
"
sleep
5
;;
#********** nginx 支持 php *********#
5)
mv
/lnmp/lnmp/nginx/conf/nginx
.conf
/lnmp/lnmp/nginx/conf/nginx
.conf.bak
cp
/lnmp/etc/nginx
.conf
/lnmp/lnmp/nginx/conf/
service nginx restart
echo
" nginx 已经支持 php"
;;
#*********** 退出 **********#
6)
exit
1
;;
*)
echo
"$color"
;;
esac
done
|
本文转自无形于有形 51CTO博客,原文链接:http://blog.51cto.com/jinchuang/1877869,如需转载请自行联系原作者