首页 > 系统 > Linux > 正文

一个简洁的全自动安装LNMP服务器环境的Shell脚本分享

2019-10-26 18:43:51
字体:
来源:转载
供稿:网友

此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP。

本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件。大家安装完可以删除该目录。

使用方法:

1、把shell脚本的内容保存为nginx_php

2、root权限下运行:
代码如下:
chmod u+x nginx_php; ./nginx_php init; ./nginx_php ins_mysql-server; ./nginx_php ins_mysql-client; ./nginx_php ins_php52; ./nginx_php ins_php52-ext; ./nginx_php ins_mysql

在脚本运行过程中需要输入一次y确认。

Shell脚本内容如下:

代码如下:
#/bash
# author:coralzd powered by www.freebsdsystem.org
# written by coralzd 2011.05.05
# version 0.1.3 build 20110505
nginx_dir="/usr/local/nginx"
php52_dir="/usr/local/php52"
mysql_dir="/usr/local/mysql"

function init()
{

LANG=C
yum -y install wget gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

read -p "Now,will download nginxphp software...Y|y:" nginxphp

case "$nginxphp" in

Y|y)

echo -n "starting download nginx_php ..."
cat > list << "EOF" &&
nginx-1.0.0.tar.gz
php-5.2.17.tar.gz
php-5.2.17-fpm-0.5.14.diff.gz
libiconv-1.13.1.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
memcache-2.2.5.tgz
mhash-0.9.9.9.tar.gz
mysql-5.1.52.tar.gz
pcre-8.10.tar.gz
eaccelerator-0.9.6.1.tar.bz2
PDO_MYSQL-1.0.2.tgz
libunwind-0.99.tar.gz
ImageMagick.tar.gz
imagick-2.3.0.tgz
google-perftools-1.6.tar.gz
fcgi.conf
php.ini
nginx.conf
php-fpm.conf
EOF
mkdir packages
for i in `cat list`
do
if [ -s packages/$i ]; then
echo "$i [found]"
else
echo "Error: $i not found!!!download now......"
wget http://www.freebsdsystem.org/linux/nginx-php/$i -P packages/
fi
done
;;

*)

echo -n "exit install script"
exit 0
;;

esac

groupadd www && useradd www -s /sbin/nologin -g www
groupadd mysql && useradd mysql -s /sbin/nologin -g mysql
echo "www and mysql user && group create!"

/bin/rm -rf list

echo -e "All of installed sucussful!"
}
function is_version()

{
if [ `uname -m` == "x86_64" ];then
tar zxf libunwind-0.99.tar.gz
tar zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
cd ../
else

echo "your system is 32bit ,not install libunwind lib!"

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表