由於Nginx是一款高效能的HTTP和反向 Proxy伺服器。Nginx在反向 Proxy,Rewrite規則,穩定性,靜態檔案處理,記憶體消耗等方面表現了很強的優勢。因此公司線上和測試環境的WEB服務大多數採用的是LNMP環境,經常要進行LNMP環境的搭建,下面是用SHELL指令碼寫的一鍵安裝LNMP環境的指令碼。
1)系統內容介紹
Centos 5.8 64位 (已測試)
Nginx: nginx-1.4.1.tar.gz
PHP: php-5.3.27.tar.gz
Mysql: mysql-5.6.5-m8.tar.gz
2)一鍵安裝LNMP環境
cd /root/sh
wget http://sourceforge.net/projects/opensourcefile/files/Install_Centos_LNMP_v.0.1.sh/download
Install_Centos_LNMP_v.0.1.sh
3)查看LNMP一鍵安裝指令碼的SHELL指令碼
cat Install_Centos_LNMP_v.0.1.sh
#!/bin/bash
#author:sfzhang
mkdir -p /software
cd /software
wget http://sourceforge.net/projects/opensourcefile/files/Centos_LNMP_v.0.1.tar.gz/download
if [ $? -eq 0 ]
then
unzip Centos_LNMP_v.0.1.tar.gz
rm -f Centos_LNMP_v.0.1.tar.gz
else
echo "Downloading http://sourceforge.net/projects/opensourcefile/files/Centos_LNMP_v.0.1.tar.gz/download failured!"
exit 1
fi
echo "Installing lnmp depend packages... "
sh /software/install_packages.sh
if [ $? -eq 0 ]
then
echo "Lnmp depend packages install sucessfull!"
else
echo "Lnmp depend packages install failured!"
exit 1
fi
echo "Installing php library files..."
sh /software/install_php_lib.sh
if [ $? -eq 0 ]
then
echo "PHP library install sucessfull!"
else
echo "PHP library install failured!"
exit 1
fi
echo "Installing mysql,please waitting..."
sh /software/install_mysql_5.6.sh
if [ $? -eq 0 ]
then
echo "mysql install sucessfull!"
else
echo "mysql install failured!"
exit 1
fi
echo "Now Installing php,please waitting..."
sh /software/install_php_5.3.sh
if [ $? -eq 0 ]
then
echo "PHP install sucessfull!"
else
echo "PHP install failured!"
exit 1
fi
echo "Installing php extensions...."
sh /software/install_php_ext.sh
if [ $? -eq 0 ]
then
echo "PHP extensions install sucessfull!"
else
echo "PHP extensions install failured!"
exit 1
fi
echo "Installing nginx....."
sh /software/install_nginx.sh
if [ $? -eq 0 ]
then
echo "Nginx install sucessfull!"
else
echo "Nginx install failured!"
exit 1
fi
echo "optimizing the environment of the lnmp!"
sh /software/install_optimiz.sh
if [ $? -eq 0 ]
then
echo "optimizing the environment of the lnmp sucessfull!"
else
echo "optimizing the environment of the lnmp failured!"
exit 1
fi
echo "Congratulations to you,a key installation LNMP is successful!"