centos6—lnmp一键安装脚本

  1. 把需要的脚本下载放到/root 目录下,然后运行本脚本即可自动化安装lnmp环境:
#!/bin/bash
#lnmp环境搭建自动化脚本 
#date 2017/8/22
#author vaedit
yum install epel-release -y
yum -y install pcre pcre-devel openssl openssl-devel gcc gcc-c++ cmake ncurses-devel libtool zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel mysql-devel openldap openldap-* libmcrypt-devel mhash mcrypt

function mysql_install(){
    cd /root
    useradd -M -s /sbin/nologin mysql
    tar xf mysql-5.5.57.tar.gz
    cd mysql-5.5.57
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysql/ -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
    make install
    ln -s /usr/local/mysql/bin/* /usr/bin
    cp support-files/my-large.cnf /etc/my.cnf -f
    cp support-files/mysql.server /etc/rc.d/init.d/mysqld
    chmod 755 /etc/init.d/mysqld
    echo "开始初始化mysql实例"
    /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
    echo "开始启动mysql"
    service mysqld start
    mysqladmin -u root password "52linux"
}

function php_install(){
    cd /root
    tar xf php-5.6.31.tar.gz
    tar xf libiconv-1.15.tar.gz
    cd libiconv-1.15
    ./configure --prefix=/usr/local/libiconv
    make && make install
    ln -sf /usr/lib64/libldap* /usr/lib
    cd /root/php-5.6.31
    ./configure     --prefix=/usr/local/php     --with-mysql     --with-mysqli=mysqlnd     --with-pdo-mysql=mysqlnd     --with-iconv-dir=/usr/local/libiconv     --with-freetype-dir     --with-jpeg-dir     --with-png-dir     --with-zlib     --with-libxml-dir=/usr     --with-gettext     --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-soap     --enable-short-tags     --enable-static     --with-xsl     --with-fpm-user=www     --with-fpm-group=www     --enable-ftp     --enable-opcache=no     --with-ldap     --with-ldap-sasl
    make && make install
    cp php.ini-production /usr/local/php/etc/php.ini
    cd /usr/local/php/etc
    cp php-fpm.conf.default php-fpm.conf
    cd /root/php-5.6.31
    cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
    chmod a+x /etc/rc.d/init.d/php-fpm
}

function nginx_install(){
useradd www -s /sbin/nologin
cd /root 
tar xf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre
make && make install
mkdir /data/www -p
chown www.www /data/www
cat >/usr/local/nginx/conf/nginx.conf <<EOF
user www www;
worker_processes  1;
events {
    use epoll;
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /data/www;
            index  index.html index.htm index.php;
        }
         location ~ .*\.(php|php5)?$
    {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /data/www/$fastcgi_script_name;    
    include fastcgi_params;
    }
    }
}
EOF
}

#检查是否安装已安装过lnmp环境
if [ -d /usr/local/mysql -o -d /usr/local/nginx -o -d /usr/local/php ];then
    read -p "改机器已安装过lnmp程序,是否继续安装【yes/no】" enter
else
    enter="yes"
fi
if [ "$enter" == "yes" ];then
     mysql_install
     if [ $? -eq 0 ];then
         echo -e ‘\e[32;40;1mmysql安装成功\e[0m‘
     else
         echo -e ‘\e[31;40;1mmysql安装失败\e[0m‘
         exit 1
     fi
     nginx_install
     if [ $? -eq 0 ];then
         echo -e ‘\e[32;40;1mnginx安装成功\e[0m‘
     else
         echo -e ‘\e[31;40;1mnginx安装失败\e[0m‘
         exit 1
     fi

     php_install
     if [ $? -eq 0 ];then
         echo -e ‘\e[32;40;1mphp安装成功\e[0m‘
     else
         echo -e ‘\e[31;40;1mphp安装失败\e[0m‘
         exit 1
     fi
    
else
    echo -e ‘\e[31;40;1mlnmp安装失败\e[0m‘
    exit 2 
fi
#程序启动判断:
/usr/local/nginx/sbin/nginx
if [ $? -eq 0 ];then
         echo -e ‘\e[32;40;1mnginx安装成功\e[0m‘
     else
         echo -e ‘\e[31;40;1mnginx安装失败\e[0m‘
         exit 1
fi
/usr/local/php/sbin/php-fpm
if [ $? -eq 0 ];then
         echo -e ‘\e[32;40;1mphp安装成功\e[0m‘
     else
         echo -e ‘\e[31;40;1mphp安装失败\e[0m‘
         exit 1
fi
时间: 2024-07-31 23:06:04

centos6—lnmp一键安装脚本的相关文章

lnmp一键安装脚本(含有np与mysql分离)

基于lanny一键安装包:(含lnmp所需软件及配置文件) 安装nginx: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo yum clean all yum makecache yum install pcre p

LAMP or LNMP 一键安装脚本

#!/bin/bash echo "It will install lamp or lnmp." sleep 1 ##check last command is OK or not. check_ok() { if [ $? != 0 ] then     echo "Error, Check the error log."     exit 1 fi } ##get the archive of the system,i686 or x86_64. ar=`arc

LNMP一键安装脚本

#!/bin/bash # INSTALL Nginx+PHP5 yum -y install libxml2* libtool* pcre* gettext* DIR=`pwd` mkdir ${DIR}/Tmp #VERSION=`cat /etc/redhat-release | awk '{print $7}' | cut -c1` VERSION=`lsb_release -r |awk '{print $2}' |cut -c1` cp -r /usr/local/src/insta

CentOS6/7一键安装LNMP(基于yum)

分享一个自己写的一键安装LNMP的脚本. CentOS6安装效果: #!/bin/bash # Author:      Zhangbin # Website:     http://qicheng0211.blog.51cto.com/ # Description: CentOS6/7一键安装lnmp(基于yum) PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH err_ec

Lnmp一键部署脚本(包含模块安装,php7,openresty+缓存等)

Lnmp一键部署脚本 个人gitpage:https://owelinux.github.io/ #!/bin/bash ##DATE:2016-7-25 ##USER:owelinux ###install wallet #######install mysql################################################## yum -y install cmake ncurses-devel bison libaio make gcc gcc-c++ mk

CentOS 6、7下IPSEC/L2TP VPN一键安装脚本(openswan+xl2tpd)

CentOS 6.7下IPSEC/L2TP VPN一键安装脚本(openswan+xl2tpd) 概念性的东西这里不再赘述,网上有太多,一键安装脚本也有很多,但是很多不能用,能用的也仅仅只是在CentOS6下使用,CentOS7基本没看到这些安装脚本.于是花了一些时间来折腾测试,写这个脚本方便以后VPN的一键安装搭建.其中用的开源软件包是openswan和xl2tpd,,中间碰到过很多很多问题,如openswan和xl2tpd之间的兼容性问题. 请容许我这样做,脚本依赖<OneinStack>

L2TP/IPSec一键安装脚本

本脚本适用环境:系统支持:CentOS6+,Debian7+,Ubuntu12+内存要求:≥128M更新日期:2017 年 05 月 28 日 关于本脚本:名词解释如下L2TP(Layer 2 Tunneling Protocol)IPSec(Internet Protocol Security)IKEv2 (Internet Key Exchange v2)能实现 IPsec 的目前总体上有 openswan,libreswan,strongswan 这3种.libreswan 是基于 ope

shell-网上lnmp一键安装讲解

shell-网上lnmp一键安装讲解 #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin       #设置系统环境变量本文出处:www.ksharpdabu.info export PATH     # # Check if user is root if [ $(id -u) != "0" ]; then                           #通过判断

ss-panel(ss-R)前后端一键安装脚本(转)

ss-panel(ss-R)前后端一键安装脚本 前几天分享了ss-panel前后端的搭建教程,现在为了练习自己的技术,写了个一键安装脚本! 请注意,本脚本仅仅适用于centos7.* 最新更新:2016/11/5 本脚本包括以下功能: 使用rpm方式搭建LNMP,比市场上的LNMP一键安装包更高效,同时减轻了CPU负担,安装的时间段而且不会安装太多依赖 安装是依赖最新的SS-panel的源码,以及最新ss-rm的代码 本脚本集成了对LNMP以及ss的前端和后端,但是部分依然需要手动操作,请看详细