码迷,mamicode.com
首页 > 其他好文 > 详细

安装 LNMP

时间:2017-04-20 20:46:44      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:efi   bash   nat   install   mirror   sock   bst   pca   open   

说明:系统为 CentOS 6 ,安装完后直接输入 ip 即可访问

#!/bin/bash

# 先安装一些依赖包
myum()
{
if ! rpm -qa | grep "^$1"
then
    yum install -y $1
else
    echo $1 has already installed.
fi
}

for p in gcc wget perl perl-devel libaio libaio-devel pcre-devel zlib-devel pcre pcre-devel openssl openssl-devel zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
do
    myum $p
done

# 安装Nginx
Install_Nginx()
{
if [ -d /usr/local/nginx ];then
    break
else    
    useradd nginx -s /sbin/nologin -M
    cd ${PACKAGE_DIR}
    if [[ `rpm -qa | grep wget` == ‘‘ ]];then yum install -y wget;fi
    wget http://nginx.org/download/nginx-1.6.3.tar.gz
    tar xf nginx-1.6.3.tar.gz
    cd nginx-1.6.3
    ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    make && make install
    cd ..
    /usr/local/nginx/sbin/nginx
fi
}

# 安装MySQL
Install_MySQL()
{
if [ -d /usr/local/mysql ];then
    break
else
    groupadd mysql
    useradd -s /sbin/nologin -g mysql -M mysql
    wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz
    tar -zxvf mysql-5.5.53-linux2.6-x86_64.tar.gz
    mv mysql-5.5.53-linux2.6-x86_64 mysql && mv mysql /usr/local/
    chown -R mysql.mysql /usr/local/mysql/
    mkdir /usr/local/mysql/data
    cd /usr/local/mysql
    ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
    cp support-files/mysql.server /etc/init.d/mysqld
    cp support-files/my-large.cnf /etc/my.cnf
    chmod +x /etc/init.d/mysqld
    /etc/init.d/mysqld start
    chkconfig --add mysqld
    chkconfig mysqld on
    echo export PATH=/usr/local/mysql/bin:$PATH >> /etc/profile
fi
}

# 安装PHP
Install_PHP()
{
if [ -d /usr/local/php ];then
    break
else
    cd ${PACKAGE_DIR}
    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
    tar -zxvf libiconv-1.14.tar.gz
    cd libiconv-1.14
    ./configure --prefix=/usr/local/libiconv
    make && make install
    cd ${PACKAGE_DIR}
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
    yum install -y libmcrypt-devel mhash mcrypt
    wget http://cn.php.net/distributions/php-5.5.38.tar.bz2
    tar -jxvf php-5.5.38.tar.bz2
    cd php-5.5.38
    ./configure     --prefix=/usr/local/php     --with-mysql=/usr/local/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-safe-mode     --enable-bcmath     --enable-shmop     --enable-sysvsem     --enable-inline-optimization     --with-curl     --with-curlwrappers     --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-zend-multibyte     --enable-static     --with-xsl     --with-fpm-user=nginx     --with-fpm-group=nginx     --enable-ftp     --enable-opcache=no
    ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
    touch ext/phar/phar.phar
    make
    make install
    cp php.ini-production /usr/local/php/lib/php.ini
    cd /usr/local/php
    cp etc/php-fpm.conf.default etc/php-fpm.conf
    /usr/local/php/sbin/php-fpm
fi
}

# 开始执行脚本
PACKAGE_DIR=/usr/local/src
Install_Nginx
Install_MySQL
Install_PHP

 

 

 

     

    

 

安装 LNMP

标签:efi   bash   nat   install   mirror   sock   bst   pca   open   

原文地址:http://www.cnblogs.com/pzk7788/p/6740658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!