一键安装lnmp脚本
前段时间一直在找一个快速部署lnmp环境的方法,也没找着,就自己写了一个,结合网上的大神们的。我的方法是脚本结合源码包,很多依赖裤都是yum安装的,这都在脚本里面,需要的源码包我都下载好了,打包成压缩包,源码包+lnmp.sh文件,上传到百度云了,需要的可以download下来:
压缩包地址:
链接:http://pan.baidu.com/s/1jHCP6iM 密码:5q4c
在这里需要说明的是,脚本下载之后,打开的时候用notepad++打开,然后全选复制之后,自己在linux下,vi lnmp.sh一个新文件,把内容粘贴进去,这样就不会报windows到Linux的错误
先上传一下脚本:
#!/bin/bash
# by huowuzhao 2017.1.
yum -y install gcc gcc-c++
if [ ! -d /home/tools ]
then
mkdir /home/tools -p
fi
cd /home/tools
PING=`ping -c www.baidu.com |grep ttl=|wc -l`
if [ "$PING" -eq ]
then
echo "Network does not work"
exit
fi
if [ -e /home/tools/pcre-8.39.tar.gz ]
then
tar xf pcre-8.39.tar.gz
else
echo "no file /home/tools/pcre-8.39.tar.gz"
fi
cd pcre-8.39 &&\
./configure
if [ $? -ne ]
then
echo "pcre configure is false"
exit
fi
make && make install
if [ $? -ne ]
then
echo "pcre make install is false"
exit
fi
cd ..
RPM=`rpm -qa|grep "openssl-"|wc -l`
if [ $RPM -ne ]
then
yum -y install openssl openssl-devel
else
echo "yum install openssl openssl-devel is error"
exit
fi
cd /home/tools
if [ ! -e nginx-1.8..tar.gz ]
then
echo " nginx-1.8.0.tar.gz is false"
exit
fi
tar xf nginx-1.8..tar.gz
cd nginx-1.8.
NGINXUSER=`cat /etc/passwd |grep nginx|wc -l`
if [ "$NGINXUSER" -eq ]
then
useradd nginx -s /sbin/nologin -M
fi
./configure --user=nginx --group=nginx --prefix=/home/nginx-1.8. --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
if [ $? -eq ]
then
make
else
echo "nginx configure is error"
exit
fi
if [ $? -eq ]
then
make install
else
echo "nginx make is error"
exit
fi
if [ $? -ne ]
then
echo "nginx make install is error"
exit
fi
cd ..
if [ -d /home/nginx-1.8./ ]
then
ln -s /home/nginx-1.8. /home/nginx
else
echo "no directory /home/nginx-1.8.0/"
exit
fi
if [ -f /etc/ld.so.conf ]
then
echo "/usr/local/lib/" >>/etc/ld.so.conf
else
echo "no file /etc/ld.so.conf"
exit
fi
if [ -d /lib64 ]
then
ln -s /usr/local/lib/libpcre.so. /lib64
else
echo "no directory /lib64"
exit
fi
/home/nginx/sbin/nginx -t
if [ $? -eq ]
then
echo "nginx is ok"
else
echo "nginx is false"
exit
fi
/home/nginx/sbin/nginx
chown -R nginx.nginx /home/nginx/*
clear
echo "==================nginx install is all finish=================="
sleep 2
cd /home/tools
echo "=====================starting cmake install======================="
tar xf cmake-3.7.1.tar.gz
cd cmake-3.7.1
./configure
if [ $? -ne 0 ]
then
echo "cmake configure is error"
exit 1
fi
gmake
if [ $? -ne 0 ]
then
echo " cmake gmake is error"
exit 1
fi
gmake install
if [ $? -ne 0 ]
then
echo " cmake gmake install is error"
exit 1
fi
cd ../
PING=`ping -c 1 www.baidu.com |grep ttl=|wc -l`
if [ "$PING" -ne 1 ]
then
echo "Network does not work"
exit 1
fi
echo "=====================starting ncurses-devel install======================="
RPM=`rpm -qa |grep ncurses-devel |wc -l`
if [ $RPM -ne 1 ]
then
yum install ncurses-devel -y
fi
echo "=====================next is install mysql...======================="
cd /home/tools/
if [ -e /home/tools/mysql-5.6.34.tar.gz ]
then
tar zxf mysql-5.6.34.tar.gz
else
echo "no file /home/tools/mysql-5.6.34.tar.gz"
fi
NGINXUSER=`cat /etc/passwd |grep mysql|wc -l`
if [ "$NGINXUSER" -eq 0 ]
then
useradd mysql -s /sbin/nologin -M
fi
cd mysql-5.6.34
cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql-5.6.34 \
-DMYSQL_DATADIR=/home/mysql-5.6.34/data \
-DMYSQL_UNIX_ADDR=/home/mysql-5.6.34/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
if [ $? -ne 0 ]
then
echo "mysql cmake is error"
exit 1
fi
make
if [ $? -ne 0 ]
then
echo "mysql make is error"
exit 1
fi
make install
if [ $? -ne 0 ]
then
echo "mysql make install is error"
exit 1
fi
echo "=====================configuration mysql======================="
if [ -d /home/mysql-5.6.34 ]
then
ln -s /home/mysql-5.6.34/ /home/mysql
else
echo "no directory /home/mysql-5.6.34/"
exit 1
fi
cd /home/mysql
cp /home/tools/my.cnf /etc/my.cnf
chown -R mysql.mysql /home/mysql/
chown -R mysql.mysql /tmp
echo "=====================mysql is INIT======================="
/home/mysql/scripts/mysql_install_db --basedir=/home/mysql --datadir=/home/mysql/data --user=mysql
INIT=`/home/mysql/scripts/mysql_install_db --basedir=/home/mysql --datadir=/home/mysql/data --user=mysql|grep OK|wc -l`
if [ "$INIT" -eq 2 ]
then
echo "=====================mysql INIT is ok====================="
fi
if [ -f /home/mysql/support-files/mysql.server ]
then
cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
else
echo "no file /home/mysql/support-files/mysql.server"
fi
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
echo 'PATH=/home/mysql/bin/:$PATH' >>/etc/profile
. /etc/profile
chkconfig mysqld on
mysqladmin -u root password '123456'
MYSQLLOGIN=`mysql -uroot -p123456 -e "select version();"|wc -l`
if [ $MYSQLLOGIN -ne 0 ]
then
echo "mysql is installed and mysql login is ok..."
else
echo "mysql don't login..."
fi
clear
echo "Pls input user@localhost and password login!!!!!"
sleep 1
clear
echo "==============other installation package=============="
cd /home/tools/
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libtool-ltdl-devel -y
yum install libxslt libxslt-devel -y
YUM=`rpm -qa zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel|wc -l`
if [ $YUM -lt 3 ]
then
echo "yum bag is error,bag is lack..."
exit 1
fi
if [ ! -e libiconv-1.9.2.tar.gz ]
then
echo "no gz libiconv-1.9.2.tar.gz"
exit 1
fi
tar zxf libiconv-1.9.2.tar.gz
cd libiconv-1.9.2
./configure --prefix=/usr/local/libiconv
if [ $? -ne 0 ]
then
echo "libiconv-1.9.2 configure is error"
exit 1
fi
make&&make install
if [ $? -ne 0 ]
then
echo "libiconv-1.9.2 make&&make install is error"
exit 1
fi
cd ../
if [ ! -e libmcrypt-2.5.8.tar.gz ]
then
echo "no gz libmcrypt-2.5.8.tar.gz"
exit 1
fi
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
if [ $? -ne 0 ]
then
echo "libmcrypt-2.5.8 configure is error"
exit 1
fi
make&&make install
if [ $? -ne 0 ]
then
echo "libmcrypt-2.5.8 make&&make install is error"
exit 1
fi
sleep 2
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
if [ $? -ne 0 ]
then
echo "libmcrypt-2.5.8/libltdl configure is error"
exit 1
fi
make&&make install
if [ $? -ne 0 ]
then
echo "libmcrypt-2.5.8/libltdl make&&make install is error"
exit 1
fi
cd ../../
if [ ! -e mhash-0.9.9.9.tar.gz ]
then
echo "no gz mhash-0.9.9.9.tar.gz"
exit 1
fi
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
if [ $? -ne 0 ]
then
echo "mhash-0.9.9.9 configure is error"
exit 1
fi
make&&make install
if [ $? -ne 0 ]
then
echo "mhash-0.9.9.9 make&&make install is error"
exit 1
fi
sleep 2
cd ../
rm -f /usr/lib64/libmcrypt.*
rm -f /usr/lib64/libmhash*
ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
if [ ! -e mcrypt-2.6.8.tar.gz ]
then
echo "no gz mcrypt-2.6.8.tar.gz"
exit 1
fi
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure LD_LIBRARY_PATH=/usr/local/lib
if [ $? -ne 0 ]
then
echo "mcrypt-2.6.8 configure is error"
exit 1
fi
make&&make install
if [ $? -ne 0 ]
then
echo "mcrypt-2.6.8 make&&make install is error"
exit 1
fi
cd ../
clear
echo "==============other installation package is ok=============="
sleep 2
echo "==================starting install php===================="
if [ ! -e php-5.6.11.tar.gz ]
then
echo "no gz php-5.6.11.tar.gz"
exit 1
fi
tar xf php-5.6.11.tar.gz
cd php-5.6.11
echo "/home/mysql-5.6.25/lib/" >>/etc/ld.so.conf
ldconfig
./configure \
--prefix=/home/php-5.6.11 \
--with-mysql=/home/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp
if [ $? -ne 0 ]
then
echo "php-5.6.11.tar.gz configure is error"
exit 1
fi
make
if [ $? -eq 0 ]
then
make install
else
echo "make is error"
exit 1
fi
ln -s /home/php-5.6.11/ /home/php
cp php.ini-production /home/php/lib/php.ini
cd /home/php/etc/
cp /home/tools/php-fpm.conf ./
CONF=`ls php-fpm.conf|wc -l`
if [ $CONF -ne 1 ]
then
echo "no file /home/php/etc/php-fpm.conf"
exit 1
fi
clear
echo "=====================php install is ok========================"
sleep 1
/home/php/sbin/php-fpm
PHPSTART=`ss -luntp |grep php-fpm|wc -l`
if [ $PHPSTART -eq 0 ]
then
echo "php-fpm is stopped..."
fi
clear
echo "===========lnmp all install is ok============="
echo "==============!!!!happy!!!!================"
echo " * * * * "
echo " * * * * * * "
echo " ***** * * * * "
echo " * * * * * * "
echo " * * * * * "
echo "==============!!!!happy!!!!================"
一键安装lnmp脚本的更多相关文章
- Centos7一键安装lnmp脚本
mkdir /root/softwarewget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.18.tar.gzwget https ...
- 一键安装LNMP(适合centos7)
1.准备工作,下载源码包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- linux一键安装vncserver脚本
title: linux一键安装vncserver脚本 date: 2016-04-11 14:32:04 tags: --- linux多数情况下是作为服务器使用的,管理员一般也喜欢使用命令行来管理 ...
- Centos6.5中 一键安装LNMP 安装Yii2.0 手工配置
1.一键安装LNMP cd /usr wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz tar zxf lnmp1.-full.tar.gz ...
- Rehat一键安装mysql脚本和备份数据库脚本
Rehat一键安装mysql脚本 ##说明:适用,Rehat 5 6 7 1.运行状态,运行成功输出mysql临时密码 2.代码如下 #!/bin/bash #获取系统信息 sudo cat /etc ...
- (转)CentOS一键安装Nginx脚本
原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本
- Linux一键安装LNMP环境
Linux一键安装LNMP环境 官方地址:https://lnmp.org/. 参考安装步骤:https://lnmp.org/install.html. 一键安装可以选择mysql版本.php版本, ...
- Linux安装swoole拓展 (一键安装lnmp后安装可用完美)
一键安装lnmp后安装可用完美 swoole(一键安装完lnmp重启下,之前出现502一直解决不了,不清楚啥情况) 找到对应php版本,在lnmp文件夹的src 1.安装swoole cd /usr/ ...
随机推荐
- javascript基础学习(五)
javascript之函数 学习要点: 函数的介绍 函数的参数 函数的属性和方法 系统函数 一.函数的介绍 1.函数就是一段javascript代码.可以分为用户自定义函数和系统函数. 如果一个函 ...
- 一个中型项目:本地校园App
好暨: 这个项目的起源于课堂老师作业的要求.老师要求一年下来完成一个构想并实现Demo.思考良久,在要提交构想的那个晚上,想到了校园App,当时团队只有两个人,但我感觉到:就是它了!项目启动时间——2 ...
- 子元素的margin-top影响父元素原因和解决办法
这个问题会出现在所有浏览器当中,原因是css2.1盒子模型中规定, In this specification, the expression collapsing margins means tha ...
- slice的用法与用量
用法:slice用于从指定值截取并返回新数组,但原数组结构不变 arrayObject.slice(start,[end]) 起始值可以为负数,-1为最后一个,end选填,但取不到end坐标的值,实际 ...
- 自定义Excel导出简易组件
1.组件原理 excel的数据存储是以xml格式存储的,所以导出Excel文件可以通过生成XML来实现.当然XML必须符合一定的格式要求. 2.组件实现 (1)新建类库文件“MyExcel” (2)添 ...
- mysql,left join on
转自http://www.oschina.net/question/89964_65912 觉得很有帮助,用来学习. 即使你认为自己已对 MySQL 的 LEFT JOIN 理解深刻,但我敢打赌,这篇 ...
- BZOJ 1059 矩阵游戏
Description 小Q是一个非常聪明的孩子,除了国际象棋,他还很喜欢玩一个电脑益智游戏--矩阵游戏.矩阵游戏在一个\(N \times N\)黑白方阵进行(如同国际象棋一般,只是颜色是随意的). ...
- Nine Great Books about Information Visualization
Nine Great Books about Information Visualization Maybe it’s anachronistic to celebrate static, print ...
- 【Java】对Web Service的理解
WSDL(Web Service Description Language)是描述Web Service的语言. 你会怎样向别人介绍你的Web service有什么功能,以及每个函数调用时的参数呢?你 ...
- how to optimize javascript performance
https://developers.google.com/speed/articles/optimizing-javascript http://developer.yahoo.com/perfor ...