echo -e “4. Deploy LNMP”
echo -e “9. Quit”
function command_status_check() {
if [ $? -ne 0 ]; then
echo $1
exit
fi
}
function install_nginx() {
cd
T
M
P
_
D
I
R
y
u
m
i
n
s
t
a
l
l
−
y
g
c
c
g
c
c
−
c
+
+
m
a
k
e
o
p
e
n
s
s
l
−
d
e
v
e
l
p
c
r
e
−
d
e
v
e
l
w
g
e
t
w
g
e
t
h
t
t
p
:
/
/
n
g
i
n
x
.
o
r
g
/
d
o
w
n
l
o
a
d
/
n
g
i
n
x
−
TMP\_DIR yum install -y gcc gcc-c++ make openssl-devel pcre-devel wget wget http://nginx.org/download/nginx-
TMP_DIR yuminstall−ygccgcc−c++makeopenssl−develpcre−develwget wgethttp://nginx.org/download/nginx−{NGINX_V}.tar.gz
tar zxf nginx-
N
G
I
N
X
_
V
.
t
a
r
.
g
z
c
d
n
g
i
n
x
−
{NGINX\_V}.tar.gz cd nginx-
NGINX_V.tar.gz cdnginx−{NGINX_V}
./configure --prefix=$INSTALL_DIR/nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-stream
command_status_check “Nginx - 平台环境检查失败!”
make -j 4
command_status_check “Nginx - 编译失败!”
make install
command_status_check “Nginx - 安装失败!”
mkdir -p $INSTALL_DIR/nginx/conf/vhost
#alias cp=cp ; cp -rf
T
M
P
_
D
I
R
/
n
g
i
n
x
−
TMP\_DIR/nginx-
TMP_DIR/nginx−{NGINX_V}/nginx.conf $INSTALL_DIR/nginx/conf
rm -rf $INSTALL_DIR/nginx/html/*
echo “ok” > $INSTALL_DIR/nginx/html/status.html
echo ‘<?php echo "ok"?>’ > $INSTALL_DIR/nginx/html/status.php
$INSTALL_DIR/nginx/sbin/nginx
command_status_check “Nginx - 启动失败!”
}
function install_php() {
cd
T
M
P
_
D
I
R
y
u
m
i
n
s
t
a
l
l
−
y
g
c
c
g
c
c
−
c
+
+
m
a
k
e
z
l
i
b
z
l
i
b
−
d
e
v
e
l
p
c
r
e
p
c
r
e
−
d
e
v
e
l
l
i
b
j
p
e
g
l
i
b
j
p
e
g
−
d
e
v
e
l
l
i
b
p
n
g
l
i
b
p
n
g
−
d
e
v
e
l
f
r
e
e
t
y
p
e
f
r
e
e
t
y
p
e
−
d
e
v
e
l
l
i
b
x
m
l
2
l
i
b
x
m
l
2
−
d
e
v
e
l
g
l
i
b
c
g
l
i
b
c
−
d
e
v
e
l
g
l
i
b
2
g
l
i
b
2
−
d
e
v
e
l
b
z
i
p
2
b
z
i
p
2
−
d
e
v
e
l
n
c
u
r
s
e
s
n
c
u
r
s
e
s
−
d
e
v
e
l
c
u
r
l
c
u
r
l
−
d
e
v
e
l
e
2
f
s
p
r
o
g
s
e
2
f
s
p
r
o
g
s
−
d
e
v
e
l
k
r
b
5
k
r
b
5
−
d
e
v
e
l
o
p
e
n
s
s
l
o
p
e
n
s
s
l
−
d
e
v
e
l
o
p
e
n
l
d
a
p
o
p
e
n
l
d
a
p
−
d
e
v
e
l
n
s
s
_
l
d
a
p
o
p
e
n
l
d
a
p
−
c
l
i
e
n
t
s
o
p
e
n
l
d
a
p
−
s
e
r
v
e
r
s
w
g
e
t
h
t
t
p
:
/
/
d
o
c
s
.
p
h
p
.
n
e
t
/
d
i
s
t
r
i
b
u
t
i
o
n
s
/
p
h
p
−
TMP\_DIR yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \ glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel \ e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel \ openldap openldap-devel nss\_ldap openldap-clients openldap-servers \ wget http://docs.php.net/distributions/php-
TMP_DIR yuminstall−ygccgcc−c++makezlibzlib−develpcrepcre−devel libjpeglibjpeg−devellibpnglibpng−develfreetypefreetype−devellibxml2libxml2−devel glibcglibc−develglib2glib2−develbzip2bzip2−develncursesncurses−develcurlcurl−devel e2fsprogse2fsprogs−develkrb5krb5−developensslopenssl−devel openldapopenldap−develnss_ldapopenldap−clientsopenldap−servers wgethttp://docs.php.net/distributions/php−{PHP_V}.tar.gz
tar zxf php-
P
H
P
_
V
.
t
a
r
.
g
z
c
d
p
h
p
−
{PHP\_V}.tar.gz cd php-
PHP_V.tar.gz cdphp−{PHP_V}
./configure --prefix=
I
N
S
T
A
L
L
_
D
I
R
/
p
h
p
−
−
w
i
t
h
−
c
o
n
f
i
g
−
f
i
l
e
−
p
a
t
h
=
INSTALL\_DIR/php \ --with-config-file-path=
INSTALL_DIR/php −−with−config−file−path=INSTALL_DIR/php/etc \
--exec-prefix=
I
N
S
T
A
L
L
_
D
I
R
/
p
h
p
−
−
w
i
t
h
−
m
y
s
q
l
i
−
−
w
i
t
h
−
m
y
s
q
l
−
−
w
i
t
h
−
p
d
o
−
m
y
s
q
l
−
−
w
i
t
h
−
g
d
−
−
b
i
n
d
i
r
=
INSTALL\_DIR/php --with-mysqli --with-mysql\ --with-pdo-mysql --with-gd --bindir=
INSTALL_DIR/php−−with−mysqli−−with−mysql −−with−pdo−mysql−−with−gd−−bindir=INSTALL_DIR/php/bin \
--sbindir=
I
N
S
T
A
L
L
_
D
I
R
/
p
h
p
/
s
b
i
n
−
−
i
n
c
l
u
d
e
d
i
r
=
INSTALL\_DIR/php/sbin --includedir=
INSTALL_DIR/php/sbin−−includedir=INSTALL_DIR/php/include \
--libdir=
I
N
S
T
A
L
L
_
D
I
R
/
p
h
p
/
l
i
b
/
p
h
p
−
−
m
a
n
d
i
r
=
INSTALL\_DIR/php/lib/php --mandir=
INSTALL_DIR/php/lib/php−−mandir=INSTALL_DIR/php/php/man \
--with-curl --with-zlib --enable-opcache --with-jpeg-dir --with-png-dir \
--with-openssl --enable-mbstring --enable-fpm --enable-hash \
command_status_check “PHP - 平台环境检查失败!”
make -j 4
command_status_check “PHP - 编译失败!”
make install
command_status_check “PHP - 安装失败!”
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
ln -s /usr/local/php/bin/php /usr/local/bin
/etc/init.d/php-fpm start
command_status_check “PHP - 启动失败!”
}
read -p “请输入编号:” number
case $number in
1)
install_nginx;;
2)
install_php;;
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!