centos6:lnmp一键搭建脚本

1.把需要的脚本下载放到/root 目录下,然后运行本脚本即可自动化安装lnmp环境:

#!/bin/bash
#lnmp环境搭建自动化脚本
#date 2017/8/22
#author vaedityum 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-10-11 04:35:08

centos6:lnmp一键搭建脚本的相关文章

centos6—lnmp一键安装脚本

把需要的脚本下载放到/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 lib

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

centos6 LNMP的搭建(linux+nginx+mysql+php)

LNMP的搭建(linux+nginx+mysql+php) 简介 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP网站服务器架构. Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统.代表版本有:debian.centos.ubuntu.fedora.gentoo等. Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器. Mysql是一个小型关系型数据库管理系统. PHP是一种在服务器端执行的嵌入HTML文档

Linux系统下LNMP一键搭建Linux、PHP、MySQL环境(适合新手搭建linux下的web生成环境)

一. 首先要解释一下,什么是LNMP,LNMP起源于LAMP,LAMP是Linux+Apache+Mysql/MariaDB+Perl/PHP/Python的缩写,这里将Web服务端的Apache替换成了资源消耗更少,更稳定的Nginx,所以LNMP就是Linux+Nginx+Mysql/MariaDB+Perl/PHP/Python的缩写: 引用LNMP一键安装包网站的简介来简单的介绍一下,为什么要选择LNMP LNMP一键安装包是什么? LNMP一键安装包是一个用Linux Shell编写的

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 #auto make install LNMP #by authors zhang 2016 #Nginx define path variable N_FILES=nginx-1.6.0.tar.gz N_FILES_DIR=nginx-1.6.0 N_PREFIX=/usr/local/nginx/ #mysql define path variable M_FILES=mysql-5.5.22.tar.gz M_FILES_DIR=mysql-5.5.22 M_PR

lnmp一键搭建环境

1.用putty链接虚拟机(这样子就可以远程粘贴复制了) (1)在linux里查看ip ifconfig  命令就可以看出来 (2)用putty链接 2.下载screen并安装 yum install screen 3.安装wget yum install wget 4.安装LNMP稳定版(https://lnmp.org/install.html)wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz && tar zxf lnmp1.4.ta

Ubuntu16.04~16.10(php7.0)网站环境一键搭建脚本

将附件下载解压上传到服务器 首先给解压出来的脚本文件给予权限(这里的文件名是:Ubuntu16.x-php7.0.sh) chmod a+x Ubuntu16.x-php7.0.sh 然后执行: sh ./Ubuntu16.x-php7.0.sh 等待过程中会出现让你设置数据库密码 最后大功告成!访问下你的网站或者服务器IP试试! 脚本下载地址:点击下载 加压密码:izchuan.com