前段时间一直在找一个快速部署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脚本的更多相关文章

  1. Centos7一键安装lnmp脚本

    mkdir /root/softwarewget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.18.tar.gzwget https ...

  2. 一键安装LNMP(适合centos7)

    1.准备工作,下载源码包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar ...

  3. Shell脚本一键安装LNMP环境

    https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...

  4. linux一键安装vncserver脚本

    title: linux一键安装vncserver脚本 date: 2016-04-11 14:32:04 tags: --- linux多数情况下是作为服务器使用的,管理员一般也喜欢使用命令行来管理 ...

  5. 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 ...

  6. Rehat一键安装mysql脚本和备份数据库脚本

    Rehat一键安装mysql脚本 ##说明:适用,Rehat 5 6 7 1.运行状态,运行成功输出mysql临时密码 2.代码如下 #!/bin/bash #获取系统信息 sudo cat /etc ...

  7. (转)CentOS一键安装Nginx脚本

    原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本

  8. Linux一键安装LNMP环境

    Linux一键安装LNMP环境 官方地址:https://lnmp.org/. 参考安装步骤:https://lnmp.org/install.html. 一键安装可以选择mysql版本.php版本, ...

  9. Linux安装swoole拓展 (一键安装lnmp后安装可用完美)

    一键安装lnmp后安装可用完美 swoole(一键安装完lnmp重启下,之前出现502一直解决不了,不清楚啥情况) 找到对应php版本,在lnmp文件夹的src 1.安装swoole cd /usr/ ...

随机推荐

  1. healthkit 记录每天用户的运动情况

    //详细操作步骤 http://www.csdn.net/article/2015-01-23/2823686-healthkit-tutorial-with-swift //官方api https: ...

  2. DataSet与DataTable基本用法

    http://files.cnblogs.com/files/monkeyZhong/DataSetExample.rar 在设计数据库操作或者XML操作等表格数据时,我们难免要跟DataSet和Da ...

  3. jdk配置环境变量(windows)

    1.配置环境变量:右击"我的电脑"-->"高级"-->"环境变量"1)在系统变量里新建"JAVA_HOME" ...

  4. Android界面布局学习总结

    参考文章: http://blog.csdn.net/shakespeare001/article/details/7843460 http://www.cnblogs.com/w-y-f/p/412 ...

  5. zoj3839-Poker Face

    #include<cstdio>int n;void P(int i,int j,int n,int f){ if(i==n){ for(int k=1;k<=n;k++)print ...

  6. 手机端QQ客服直接跳转到QQ

    企业QQ呼出QQ对话框方法 1.手机端链接是这样的:mqqwpa://im/chat?chat_type=wpa&uin=386807630&version=1&src_typ ...

  7. 阿里云 centos vim 显示中文 乱码

    开始以为是vim 设置编码的问题 :网上搜  改 .vimrc    无效!!! 后转战  是不是系统里面没有中文字体 1.先从你本机 C:\Windows\Fonts 拷贝或者网络上下载你想要安装的 ...

  8. 分页插件jquery.simplePagination.js使用

    利用ecshop后台,利用插件更改分页显示样式遇到的问题,由于是利用Ajax获取数据进行页面数据更新?所以出现了以下情况: 初始化页面前 : 分页更新后: 点击后出现了分页插件内容消失, 原因:分页一 ...

  9. Day11 线程、进程、协程

    创建线程第一种:import threadingdef f1(arg): print(arg) t = threading.Thread(target=f1, args=(123,))#t.start ...

  10. Json数据时间格式的处理

    方法: using Newtonsoft.Json; using Newtonsoft.Json.Converters;//需引入Newtonsoft.Json.dll public class Co ...