日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
LNMP(nginx+mysql+php)環(huán)境/架構(gòu)一鍵安裝腳本

LNMP(nginx+mysql+php)環(huán)境/架構(gòu) 一鍵安裝腳本,該腳本已經(jīng)在CentOS 7.1 上測(cè)試通過(guò),用時(shí)27分,硬件環(huán)境(1G,1U)。該腳本有安裝PHP加速器xcache:

德保網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,德保網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為德保上千多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的德保做網(wǎng)站的公司定做!

#!/bin/bash

#該腳本的作用 :在線一鍵部署LNMP
#Write      :King
#Date      :2015-03-19

#mysql      數(shù)據(jù)存放目錄為/data/mysql
#php        主配置文件在 /usr/local/php/etc
#nginx      web 程序目錄/usr/local/nginx/html/index,主配置目錄 /usr/local/nignx/conf/nginx.conf

#源碼下載目錄
SoftDir='/usr/local/src'

#定義安裝日志路徑
LOG_INS='/var/log/install.log'

#定義Mysql 源碼目錄:
MysqlS='/usr/local/mysql'

#define make
function MAKE(){
    if [ `echo $?` -eq 0 ];then
            make >> $LOG_INS 2>&1
        else
            exit
    fi
}

#define make install
function MAKE_INS(){
    if [ `echo $?` -eq 0 ];then
            make install >> $LOG_INS 2>&1
        else
            exit
    fi
}

#安裝系統(tǒng)擴(kuò)展源:http://dl.Fedoraproject.org/pub/epel
if [ `awk '{print $3}' /etc/RedHat-release |awk -F '.' '{print $1}'` -eq 6 ];then
                rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm >> $LOG_INS 2>&1
        elif [ `awk '{print $4}' /etc/redhat-release |awk -F '.' '{print $1}'` -eq 7 ];then
                rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm >> $LOG_INS 2>&1
fi

#安裝系統(tǒng)運(yùn)維包:
yum install -y lrzsz gcc gcc-c++  bzip2 bzip2-devel make man vim tree unzip wget lua-devel lua-static patch libxml2-devel libxslt libxslt-devel gd gd-devel ntp ntpdate screen sysstat tree rsync lsof autoconf gettext  gettext-devel automake libtool git >> $LOG_INS 2>&1

#升級(jí)系統(tǒng):
yum update -y >> $LOG_INS 2>&1

#替換selinux 配置:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

#下載安裝Mysql:  http://cdn.mysql.com/Downloads
cd $SoftDir && wget -q http://www.linuser.com/share/soft/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

#解壓:
tar zxf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

#移動(dòng)解壓目錄病重命名Mysql:
mv mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql

#添加mysql 系統(tǒng)用戶:
if [ -z `grep mysql /etc/passwd` ] ;then
        useradd -s /sbin/nologin mysql
fi

#創(chuàng)建mysql 初始化數(shù)據(jù)目錄:
if [ ! -d "/data/mysql" ] ;then
        mkdir -p /data/mysql
fi

#將mysql 初始化目錄所屬主和組修改為mysql:
chown -R mysql.mysql /data/mysql/

#初始化
cd $MysqlS && ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql  >> $LOG_INS 2>&1

#備份系統(tǒng)默認(rèn)的my.cnf 文件:
mv /etc/my.cnf{,.bak}

#復(fù)制mysql 的 主配置文件到etc 目錄下病重命名為my.cnf
 \cp support-files/my-default.cnf /etc/my.cnf

#復(fù)制mysql 的啟動(dòng)腳本到/etc/init.d 目錄下:
 \cp support-files/mysql.server /etc/init.d/mysqld

#賦予啟動(dòng)755 權(quán)限:
chmod 755 /etc/init.d/mysqld

#修改my.cnf 文件配置如下:
cat << EOF > /etc/my.cnf
[mysqld]
pid-file=/data/mysql/mysql.pid
log-error=/var/log/mysql.log
datadir = /data/mysql
basedir = /usr/local/mysql
character-set-server=utf8
port = 3306
socket = /tmp/mysql.sock
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 16M
thread_concurrency = 8
binlog_format=mixed
server-id = 1
slow-query-log = 1
slow-query-log-file = /data/mysql/mysql-slow.log
log-bin = mysql-bin
log-bin-index = mysql-bin.index
symbolic-links = 0
skip-name-resolve

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8

[mysqldump]
quick
max_allowed_packet = 16M

#[mysqld_safe]

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
EOF

#啟動(dòng)mysql:
service mysqld start

if [ `echo $?` -eq 0 ] ;then
        echo "Mysql started"
else
        exit
fi

#將Mysqld 設(shè)置為隨機(jī)啟動(dòng):
chkconfig --add mysqld && chkconfig mysqld on

#=====================================                安裝LTP          =======================================
#下載LTP:
cd $SoftDir &&  wget -q http://www.linuser.com/share/soft/ltp-full-20150420.tar.bz2

#解壓
tar jxf ltp-full-20150420.tar.bz2

#配置編譯參數(shù):
cd ./ltp-full-20150420 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=====================================                安裝openssl1.0.2          =======================================
#下載openssl:
cd $SoftDir &&  wget -q http://www.linuser.com/share/soft/openssl-1.0.2.tar.gz

#解壓:
tar zxf openssl-1.0.2.tar.gz

#進(jìn)入解壓目錄,配置編譯參數(shù):
cd ./openssl-1.0.2 && ./config >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=====================================                安裝curl-7.45.0          =======================================
#下載:
cd $SoftDir &&  wget -q http://www.linuser.com/share/soft/curl-7.45.0.tar.gz

#解壓:
tar zxf curl-7.45.0.tar.gz

#進(jìn)入解壓目錄,配置編譯參數(shù):
cd ./curl-7.45.0 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=====================================                安裝libmcrypt-2.5.8                  ==================================
#下載:
cd $SoftDir &&  wget -q http://www.linuser.com/share/soft/libmcrypt-2.5.8.tar.gz

#解壓:
tar zxf libmcrypt-2.5.8.tar.gz

#進(jìn)入解壓目錄,配置編譯參數(shù):
cd ./libmcrypt-2.5.8 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=======================================        安裝PHP 5.5.22          ====================================
#下載PHP 5.5.22
cd $SoftDir &&  wget -q http://www.linuser.com/share/soft/php-5.5.30.tar.gz

#解壓PHP:
tar zxf php-5.5.30.tar.gz

#添加php-fpm 用戶,不允許登陸系統(tǒng)
useradd -s /sbin/nologin php-fpm

#進(jìn)入PHP解壓目錄,配置編譯參數(shù):
cd ./php-5.5.30 && ./configure --prefix=/usr/local/php  --with-config-file-path=/usr/local/php/etc  --enable-fpm  --with-fpm-user=php-fpm  --with-fpm-group=php-fpm  --with-mysql=/usr/local/mysql  --with-mysql-sock=/tmp/mysql.sock  --with-libxml-dir  --with-gd  --with-jpeg-dir  --with-png-dir  --with-freetype-dir  --with-iconv-dir  --with-zlib-dir  --with-mcrypt  --enable-soap  --enable-gd-native-ttf  --enable-ftp  --enable-mbstring  --enable-exif  --enable-zend-multibyte  --disable-ipv6  --with-pear  --with-curl --with-openssl --with-mysqli --enable-mysqlnd --with-gettext >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#復(fù)制Php 主配置:
 \cp php.ini-production /usr/local/php/etc/php.ini

#創(chuàng)建php-fpm 主配置文件:
cat < /usr/local/php/etc/php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = 127.0.0.1:9000
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
EOF

#測(cè)試php-fpm 配置:
/usr/local/php/sbin/php-fpm -t
if [ `echo $?` -eq 0 ];then
        echo "php-fpm installed successfully"
else
        exit
fi

#拷貝php-fpm 啟動(dòng)腳本:
 \cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

#賦予腳本可執(zhí)行權(quán)限:
chmod 755 /etc/init.d/php-fpm

#關(guān)閉php 版本信息:
sed -i 's/expose_php = On/expose_php = Off/g' /usr/local/php/etc/php.ini

#將php-fpm 寫入隨機(jī)啟動(dòng):
chkconfig --add php-fpm && chkconfig php-fpm on

#啟動(dòng)php-fpm
service php-fpm start

#=======================================        安裝pcre2-10.00                ====================================
#下載
cd $SoftDir && wget -q http://www.linuser.com/share/soft/pcre-8.37.tar.gz

#解壓:
tar zxf pcre-8.37.tar.gz

#接入pcre,配置編譯參數(shù):
cd ./pcre-8.37 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=======================================        添加libmaxminddb        ====================================
#下載:
cd $SoftDir && wget -q http://www.linuser.com/share/soft/libmaxminddb-1.1.1.tar.gz

#解壓:
tar zxf libmaxminddb-1.1.1.tar.gz

cd ./libmaxminddb-1.1.1 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=======================================        添加geoip2模塊                ====================================
#下載
cd $SoftDir && wget -q  http://www.linuser.com/share/soft/ngx_http_geoip2_module-master.zip

#解壓:
unzip ngx_http_geoip2_module-master.zip >> $LOG_INS 2>&1

#=======================================        添加libuwind              ====================================
#下載:
cd $SoftDir && wget -q http://www.linuser.com/share/soft/libunwind-1.1.tar.gz

#解壓:
tar zxf libunwind-1.1.tar.gz

#進(jìn)入解壓目錄,配置編譯參數(shù)::
cd ./libunwind-1.1 && ./configure >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#=======================================        添加gperftools                ====================================
#下載:
cd $SoftDir && wget -q http://www.linuser.com/share/soft/gperftools-master.zip

#解壓:
unzip gperftools-master.zip

#進(jìn)入解壓目錄,執(zhí)行autogen.sh 生產(chǎn)配置文件:
cd ./gperftools-master && ./autogen.sh  >> $LOG_INS 2>&1

#配置編譯參數(shù):
if [ `echo $?` -eq 0 ];then
                ./configure >> $LOG_INS 2>&1
        else
                exit
fi

#編譯及安裝
MAKE && MAKE_INS

#=======================================        安裝Tengine 2.1.0          ====================================
#下載
cd $SoftDir && wget -q http://www.linuser.com/share/soft/nginx-1.8.0.tar.gz
#解壓:
tar zxf nginx-1.8.0.tar.gz

#進(jìn)入解壓目錄,配置編譯參數(shù):
cd ./nginx-1.8.0 && ./configure --prefix=/usr/local/nginx --with-http_realip_module  --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module  --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --http-log-path=/var/log/nginx_access.log --with-google_perftools_module --with-pcre=/usr/local/src/pcre-8.37 --with-openssl=/usr/local/src/openssl-1.0.2 --add-module=/usr/local/src/ngx_http_geoip2_module-master >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#設(shè)置軟鏈接
ln -s /usr/local/lib/libmaxminddb.so.0 /usr/lib64
ln -s /usr/local/lib/libprofiler.so.0 /usr/lib64
ln -s /usr/local/lib/libunwind.so.8 /usr/lib64

#檢測(cè)初始化完成的nginx 配置是否有問(wèn)題
/usr/local/nginx/sbin/nginx  -t
if [ `echo $?` -eq 0 ];then
        echo "Nginx installed successfully!"
else
        exit
fi

#創(chuàng)建nginx 啟動(dòng)腳本
cat < /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings

NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"

start() {
        echo -n \$"Starting \$prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon \$NGINX_SBIN -c \$NGINX_CONF
        RETVAL=\$?
        echo
        return \$RETVAL
}

stop() {
        echo -n \$"Stopping \$prog: "
        killproc -p \$NGINX_PID \$NGINX_SBIN -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=\$?
        echo
        return \$RETVAL
}

reload(){
        echo -n \$"Reloading \$prog: "
        killproc -p \$NGINX_PID \$NGINX_SBIN -HUP
        RETVAL=\$?
        echo
        return \$RETVAL
}

restart(){
        stop
        start
}

configtest(){
    \$NGINX_SBIN -c \$NGINX_CONF -t
    return 0
}

case "\$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: \$0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac

exit \$RETVAL
EOF

#賦予腳本可執(zhí)行權(quán)限
chmod 755 /etc/init.d/nginx

#備份nginx主配置文件
 \cp /usr/local/nginx/conf/nginx.conf{,.bak}

#重新nginx 配置:
cat << EOF > /usr/local/nginx/conf/nginx.conf
error_log /var/log/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include      mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
        server_tokens off;
    server {
        listen      80;
        server_name  localhost;
        location / {
            root  html;
            index  index.html index.htm index.php;
        }
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }
        location ~ \.php\$ {
            root          html;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
EOF

#創(chuàng)建PHP測(cè)試文件:
echo "" >/usr/local/nginx/html/index.php

#備份index.html:
mv /usr/local/nginx/html/index.html{,.bak}

#啟動(dòng)nginx:
service nginx start

#將nginx 寫入隨機(jī)啟動(dòng):
chkconfig --add nginx && chkconfig nginx on

#開啟防火墻的80端口
iptables -I INPUT -p tcp --dport 80 -j ACCEPT

#保存防火墻配置
service iptables save

#重啟防火墻:
service iptables restart

#設(shè)置nginx、mysql 及php 的環(huán)境變量:
echo "PATH=$PATH:/usr/local/php/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:/usr/local/php/sbin" >> /etc/profile

#刷新環(huán)境變量配置,使其立即生效:
source /etc/profile

##=======================================        安裝php 加速器 xcache 3.2.0        ====================================
#官方地址:http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz

cd $SoftDir && wget -q http://www.linuser.com/share/soft/xcache-3.2.0.tar.gz

#解壓
tar zxf xcache-3.2.0.tar.gz

#執(zhí)行phpize,生成xcache 的configure 文件
cd ./xcache-3.2.0 && /usr/local/php/bin/phpize --clean &&  /usr/local/php/bin/phpize

#配置編譯參數(shù):
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config >> $LOG_INS 2>&1

#編譯及安裝
MAKE && MAKE_INS

#將xcache 結(jié)合php
echo "extemsiobn_dir='/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/'" >> /usr/local/php/etc/php.ini
echo "extension=xcache.so" >> /usr/local/php/etc/php.ini

#檢測(cè)php 是否有誤:
/usr/local/php/sbin/php-fpm -t

#重啟php-fpm:
service php-fpm restart


當(dāng)前題目:LNMP(nginx+mysql+php)環(huán)境/架構(gòu)一鍵安裝腳本
網(wǎng)頁(yè)網(wǎng)址:http://www.dlmjj.cn/article/djppeoo.html