阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

基于Tengine部署LNMP环境

124次阅读
没有评论

共计 19933 个字符,预计需要花费 50 分钟才能阅读完成。

基于 Tengine 部署 LNMP 环境

Tengine-2.0.0
MySQL-5.6.15
Php-5.3.3
CentOS-6.3
源码安装、配置 mysql-5.6.15
安装
从 5.6 开始,mysql 用 cmake 替代了大家熟悉的 configure
yum install gcc gcc++ cmake

下载源码。。。
tar zxf mysql-5.6.15.tar.gz
cd mysql-5.6.15
cmake ./            #这样就会安装到 /usr/local/mysql/。
make
make install

创建 mysql 用户,赋予权限
useradd mysql
chown -R mysql.mysql/usr/local/mysql

配置
初始化 mysql
cd /usr/local/mysql/scripts
./mysql_install_db–user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

配置 my.cnf(/etc/my.cnf)
[client]
port = 3306
socket = /tmp/mysql5.sock
# Here follows entries forsome specific programs
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /tmp/mysql5.sock
basedir = /usr/local/mysql
datadir =/usr/local/mysql/data
open_files_limit = 10240
server-id = 1
character-set-server = utf8
skip-name-resolve
max_connections = 1000
max_connect_errors = 100000
max_allowed_packet = 512M
max_heap_table_size = 1024M
max_length_for_sort_data =4096
back_log=100
interactive_timeout = 600
wait_timeout = 600
default-storage-engine =InnoDB
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit =2k
thread_cache_size = 300
table_open_cache = 1024
tmp_table_size = 256M
#*********** Logs relatedsettings ***********
long_query_time = 3
log_output = FILE
slow_query_log = 1
log_queries_not_using_indexes
#*********** MyISAMSpecific options ***********
key_buffer_size = 32M
bulk_insert_buffer_size =64M
myisam_sort_buffer_size =128M
myisam_max_sort_file_size =10G
myisam_repair_threads = 1
myisam_recover
#*********** INNODBSpecific options ***********
innodb_file_per_table
transaction-isolation =READ-COMMITTED
innodb_additional_mem_pool_size= 128M
innodb_buffer_pool_size =10240M
innodb_data_file_path =ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency =0
innodb_log_buffer_size =16M
innodb_log_file_size = 256M
innodb_log_files_in_group =2
innodb_flush_log_at_trx_commit= 2
innodb_max_dirty_pages_pct= 80
innodb_lock_wait_timeout =120
innodb_flush_method=O_DIRECT
[mysqldump]
quick
max_allowed_packet = 512M
[mysql]
no-auto-rehash
# Remove the next commentcharacter if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192

编辑启动文件(/etc/init.d/mysqld)
#!/bin/sh
#
# mysqld        This shell script takes care ofstarting and stopping
#              the MySQL subsystem (mysqld).
#
# chkconfig: – 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile:/var/run/mysqld/mysqld.pid
# Source function library.
./etc/rc.d/init.d/functions
# Source networkingconfiguration.
. /etc/sysconfig/network
exec=”/usr/local/mysql/bin/mysqld_safe”
prog=”mysqld”
# Set timeouts here so theycan be overridden from /etc/sysconfig/mysqld
STARTTIMEOUT=120
STOPTIMEOUT=60
[-e /etc/sysconfig/$prog]&& . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
# extract value of a MySQLoption from config files
# Usage: get_mysql_optionSECTION VARNAME DEFAULT
# result is returned in$result
# We use my_print_defaultswhich prints all options from multiple files,
# with the more specificones later; hence take the last match.
get_mysql_option(){
      result=`/usr/local/mysql/bin/my_print_defaults “$1″ | sed -n”s/^–$2=//p” | tail -n 1`
        if [-z “$result”]; then
            # not found, use default
            result=”$3″
        fi
}
get_mysql_option mysqlddatadir “/usr/local/mysql/data”
datadir=”$result”
get_mysql_option mysqldsocket “/tmp/mysql5.sock”
socketfile=”$result”
get_mysql_optionmysqld_safe log-error “/d1/data/bj-idc4-proxy51.err”
errlogfile=”$result”
get_mysql_option mysqld_safepid-file “/usr/local/mysql/data/bj-idc4-proxy51.pid”
mypidfile=”$result”
start(){
    [-x $exec] || exit 5
    # check to see if it’s already running
    RESPONSE=`/usr/local/mysql/bin/mysqladmin–socket=”$socketfile” –user=UNKNOWN_MYSQL_USER ping 2>&1`
    if [$? = 0]; then
        # already running, do nothing
        action $”Starting $prog: “/bin/true
        ret=0
    elif echo “$RESPONSE” | grep -q”Access denied for user”
    then
        # already running, do nothing
        action $”Starting $prog: “/bin/true
        ret=0
    else
        # prepare for start
        touch “$errlogfile”
        chown mysql:mysql”$errlogfile”
        chmod 0640 “$errlogfile”
        [-x /sbin/restorecon] &&/sbin/restorecon “$errlogfile”
        if [! -d “$datadir/mysql”]; then
            # First, make sure $datadir isthere with correct permissions
            if [! -e “$datadir” -a !-h “$datadir”]
            then
                mkdir -p “$datadir”|| exit 1
          fi
            chown mysql:mysql”$datadir”
            chmod 0755 “$datadir”
            [-x /sbin/restorecon] &&/sbin/restorecon “$datadir”
            # Now create the database
            action $”Initializing MySQLdatabase: ” /usr/local/mysql/scripts/mysql_install_db–datadir=”$datadir” –user=mysql
            ret=$?
            chown -R mysql:mysql”$datadir”
            if [$ret -ne 0] ; then
                return $ret
            fi
        fi
        chown mysql:mysql “$datadir”
        chmod 0755 “$datadir”
        # Pass all the options determinedabove, to ensure consistent behavior.
        # In many cases mysqld_safe wouldarrive at the same conclusions anyway
        # but we need to be sure.  (An exception is that we don’t force the
        # log-error setting, since this scriptdoesn’t really depend on that,
        # and some users might prefer toconfigure logging to syslog.)
        # Note: set –basedir to prevent probesthat might trigger SELinux
        # alarms, per bug #547485
        $exec  –datadir=”$datadir” –socket=”$socketfile” \
              –pid-file=”$mypidfile” \
                –basedir=/usr/local/mysql–user=mysql >/dev/null 2>&1 &
        safe_pid=$!
        # Spin for a maximum of N secondswaiting for the server to come up;
        # exit the loop immediately ifmysqld_safe process disappears.
        # Rather than assuming we know a validusername, accept an “access
        # denied” response as meaning theserver is functioning.
        ret=0
        TIMEOUT=”$STARTTIMEOUT”
        while [$TIMEOUT -gt 0]; do
            RESPONSE=`/usr/bin/mysqladmin–socket=”$socketfile” –user=UNKNOWN_MYSQL_USER ping 2>&1`&& break
            echo “$RESPONSE” | grep-q “Access denied for user” && break
            if ! /bin/kill -0 $safe_pid2>/dev/null; then
                echo “MySQL Daemon failedto start.”
                ret=1
                break
            fi
            sleep 1
            let TIMEOUT=${TIMEOUT}-1
        done
        if [$TIMEOUT -eq 0]; then
            echo “Timeout error occurredtrying to start MySQL Daemon.”
            ret=1
        fi
        if [$ret -eq 0]; then
            action $”Starting $prog:” /bin/true
            touch $lockfile
        else
            action $”Starting $prog:” /bin/false
        fi
    fi
    return $ret
}
stop(){
        if [! -f “$mypidfile”];then
            # not running; per LSB standardsthis is “ok”
            action $”Stopping $prog:” /bin/true
            return 0
        fi
        MYSQLPID=`cat “$mypidfile”`
        if [-n “$MYSQLPID”]; then
            /bin/kill “$MYSQLPID”>/dev/null 2>&1
            ret=$?
            if [$ret -eq 0]; then
              TIMEOUT=”$STOPTIMEOUT”
                while [$TIMEOUT -gt 0]; do
                    /bin/kill -0″$MYSQLPID” >/dev/null 2>&1 || break
                    sleep 1
                    let TIMEOUT=${TIMEOUT}-1
                done
                if [$TIMEOUT -eq 0]; then
                    echo “Timeout erroroccurred trying to stop MySQL Daemon.”
                    ret=1
                    action $”Stopping$prog: ” /bin/false
                else
                    rm -f $lockfile
                    rm -f”$socketfile”
                    action $”Stopping$prog: ” /bin/true
                fi
            else
                action $”Stopping $prog:” /bin/false
            fi
        else
            # failed to read pidfile, probablyinsufficient permissions
            action $”Stopping $prog:” /bin/false
            ret=4
        fi
        return $ret
}
restart(){
    stop
    start
}
condrestart(){
    [-e $lockfile] && restart || :
}
# See how we were called.
case “$1” in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status -p “$mypidfile” $prog
    ;;
  restart)
    restart
    ;;
  condrestart|try-restart)
    condrestart
    ;;
  reload)
    exit 3
    ;;
  force-reload)
    restart
    ;;
  *)
    echo $”Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload}”
    exit 2
esac
exit $?

Tengine 的详细介绍:请点这里
Tengine 的下载地址:请点这里

相关阅读

CentOS 6.4 制作 Tengine 的 rpm 包 http://www.linuxidc.com/Linux/2013-12/93786.htm

Tengine 动态开启模块试用 http://www.linuxidc.com/Linux/2012-12/75849.htm

CentOS 6.3 用 ICC 编译 PHP5.4.8+Percona5.5.27+Tengine1.4.1 http://www.linuxidc.com/Linux/2012-12/76636.htm

基于淘宝 Tengine 和 Scribe 的 WEB 日志收集方案 http://www.linuxidc.com/Linux/2012-02/52997.htm

基于 Tengine 部署 LNMP 环境 http://www.linuxidc.com/Linux/2014-01/95148.htm

源码安装、配置 tengine-2.0.0
安装
安装 pcre
yum install pcre pcre-devel

安装 tengine
./configure–prefix=/usr/local/tengine
make
make install

配置
mkdir -p/usr/local/tengine/conf/conf.d/
useradd -s /sbin/nologinapache

编辑 tengine 配置文件(/usr/local/tengine/conf/nginx.conf)
user  apache apache;
worker_processes  16;
worker_cpu_affinity auto;
pid        /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
    use epoll;
    worker_connections  51200;
}
http {
    include      mime.types;
    default_type  application/octet-stream;
    #charset gb2312;
    charset utf-8;
    server_names_hash_bucket_size 128;
    client_max_body_size 10m;
    log_format main ‘$time_local\t$server_addr\t$request_uri\t$query_string\t$request_time\t$remote_addr\t’
                  ‘$http_x_forwarded_for\t$http_user_agent\t’
                  ‘$http_cookie\t$http_referer\t$server_name\t$status’;
    access_log on;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 128k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
    fastcgi_intercept_errors on;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers    16 32k;
    gzip_http_version 1.1;
    gzip_types  text/plain application/x-Javascript text/css application/xml;
    include conf.d/*;
}

配置 vhost 配置文件(/usr/local/tengine/conf/conf.d/vhost.conf)
server {
        listen      80;
        index index.php;
        root /d1/www/vhost/;
        location ~ .*\.php?$ {
            include    fastcgi.conf;
            access_log  /var/log/nginx/vhost_access.log;
        }
  }

编辑 tengine 启动文件(/etc/init.d/tengine)
#!/bin/sh
#
# nginx – this scriptstarts and stops the nginx daemon
#
# chkconfig:  – 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#              proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:    /var/run/nginx.pid
# Source function library.
./etc/rc.d/init.d/functions
# Source networkingconfiguration.
. /etc/sysconfig/network
# Check that networking isup.
[“$NETWORKING” =”no”] && exit 0
nginx=”/usr/local/tengine/sbin/nginx”
prog=$(basename $nginx)
sysconfig=”/etc/sysconfig/$prog”
lockfile=”/var/lock/subsys/nginx”
pidfile=”/var/run/${prog}.pid”
NGINX_CONF_FILE=”/usr/local/tengine/conf/nginx.conf”
[-f $sysconfig]&& . $sysconfig
start() {
    [-x $nginx] || exit 5
    [-f $NGINX_CONF_FILE] || exit 6
    echo -n $”Starting $prog: “
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [$retval -eq 0] && touch $lockfile
    return $retval
}
stop() {
    echo -n $”Stopping $prog: “
    killproc -p $pidfile $prog
    retval=$?
    echo
    [$retval -eq 0] && rm -f$lockfile
    return $retval
}
restart() {
    configtest_q || return 6
    stop
    start
}
reload() {
    configtest_q || return 6
    echo -n $”Reloading $prog: “
    killproc -p $pidfile $prog -HUP
    echo
}
configtest() {
    $nginx -t -c $NGINX_CONF_FILE
}
configtest_q() {
    $nginx -t -q -c $NGINX_CONF_FILE
}
rh_status() {
    status $prog
}
rh_status_q() {
    rh_status >/dev/null 2>&1
}
# Upgrade the binary withno downtime.
upgrade() {
    localoldbin_pidfile=”${pidfile}.oldbin”
    configtest_q || return 6
    echo -n $”Upgrading $prog: “
    killproc -p $pidfile $prog -USR2
    retval=$?
    sleep 1
    if [[-f ${oldbin_pidfile} && -f${pidfile} ]];  then
        killproc -p $oldbin_pidfile $prog -QUIT
        success $”$prog onlineupgrade”
        echo
        return 0
    else
        failure $”$prog onlineupgrade”
        echo
        return 1
    fi
}
# Tell nginx to reopen logs
reopen_logs() {
    configtest_q || return 6
    echo -n $”Reopening $prog logs: “
    killproc -p $pidfile $prog -USR1
    retval=$?
    echo
    return $retval
}
case “$1” in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest|reopen_logs)
        $1
        ;;
    force-reload|upgrade)
        rh_status_q || exit 7
        upgrade
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    status|status_q)
        rh_$1
        ;;
    condrestart|try-restart)
        rh_status_q || exit 7
        restart
            ;;
    *)
        echo $”Usage: $0{start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}”
        exit 2
esac

yum 安装 php

yum install php php-develphp-MySQL php-fpm

配置 php(/usr/local/tengine/conf/fastcgi.conf)
在文件最上面加上这两行配置:
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;

启动服务
/etc/init.d/mysqld start
/etc/init.d/tengine start
/etc/init.d/php-fpm start
chkconfig mysqld on
chkconfig tengine on
chkconfig php-fpm on

相关阅读:

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 6.4 下的 LNMP 生产环境搭建及安装脚本 http://www.linuxidc.com/Linux/2013-11/92428.htm

生产环境实用之 LNMP 架构的编译安装 +SSL 加密实现 http://www.linuxidc.com/Linux/2013-05/85099.htm

LNMP 全功能编译安装 for CentOS 6.3 笔记 http://www.linuxidc.com/Linux/2013-05/83788.htm

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

基于 Tengine 部署 LNMP 环境

Tengine-2.0.0
MySQL-5.6.15
Php-5.3.3
CentOS-6.3
源码安装、配置 mysql-5.6.15
安装
从 5.6 开始,mysql 用 cmake 替代了大家熟悉的 configure
yum install gcc gcc++ cmake

下载源码。。。
tar zxf mysql-5.6.15.tar.gz
cd mysql-5.6.15
cmake ./            #这样就会安装到 /usr/local/mysql/。
make
make install

创建 mysql 用户,赋予权限
useradd mysql
chown -R mysql.mysql/usr/local/mysql

配置
初始化 mysql
cd /usr/local/mysql/scripts
./mysql_install_db–user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

配置 my.cnf(/etc/my.cnf)
[client]
port = 3306
socket = /tmp/mysql5.sock
# Here follows entries forsome specific programs
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /tmp/mysql5.sock
basedir = /usr/local/mysql
datadir =/usr/local/mysql/data
open_files_limit = 10240
server-id = 1
character-set-server = utf8
skip-name-resolve
max_connections = 1000
max_connect_errors = 100000
max_allowed_packet = 512M
max_heap_table_size = 1024M
max_length_for_sort_data =4096
back_log=100
interactive_timeout = 600
wait_timeout = 600
default-storage-engine =InnoDB
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit =2k
thread_cache_size = 300
table_open_cache = 1024
tmp_table_size = 256M
#*********** Logs relatedsettings ***********
long_query_time = 3
log_output = FILE
slow_query_log = 1
log_queries_not_using_indexes
#*********** MyISAMSpecific options ***********
key_buffer_size = 32M
bulk_insert_buffer_size =64M
myisam_sort_buffer_size =128M
myisam_max_sort_file_size =10G
myisam_repair_threads = 1
myisam_recover
#*********** INNODBSpecific options ***********
innodb_file_per_table
transaction-isolation =READ-COMMITTED
innodb_additional_mem_pool_size= 128M
innodb_buffer_pool_size =10240M
innodb_data_file_path =ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency =0
innodb_log_buffer_size =16M
innodb_log_file_size = 256M
innodb_log_files_in_group =2
innodb_flush_log_at_trx_commit= 2
innodb_max_dirty_pages_pct= 80
innodb_lock_wait_timeout =120
innodb_flush_method=O_DIRECT
[mysqldump]
quick
max_allowed_packet = 512M
[mysql]
no-auto-rehash
# Remove the next commentcharacter if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192

编辑启动文件(/etc/init.d/mysqld)
#!/bin/sh
#
# mysqld        This shell script takes care ofstarting and stopping
#              the MySQL subsystem (mysqld).
#
# chkconfig: – 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile:/var/run/mysqld/mysqld.pid
# Source function library.
./etc/rc.d/init.d/functions
# Source networkingconfiguration.
. /etc/sysconfig/network
exec=”/usr/local/mysql/bin/mysqld_safe”
prog=”mysqld”
# Set timeouts here so theycan be overridden from /etc/sysconfig/mysqld
STARTTIMEOUT=120
STOPTIMEOUT=60
[-e /etc/sysconfig/$prog]&& . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
# extract value of a MySQLoption from config files
# Usage: get_mysql_optionSECTION VARNAME DEFAULT
# result is returned in$result
# We use my_print_defaultswhich prints all options from multiple files,
# with the more specificones later; hence take the last match.
get_mysql_option(){
      result=`/usr/local/mysql/bin/my_print_defaults “$1″ | sed -n”s/^–$2=//p” | tail -n 1`
        if [-z “$result”]; then
            # not found, use default
            result=”$3″
        fi
}
get_mysql_option mysqlddatadir “/usr/local/mysql/data”
datadir=”$result”
get_mysql_option mysqldsocket “/tmp/mysql5.sock”
socketfile=”$result”
get_mysql_optionmysqld_safe log-error “/d1/data/bj-idc4-proxy51.err”
errlogfile=”$result”
get_mysql_option mysqld_safepid-file “/usr/local/mysql/data/bj-idc4-proxy51.pid”
mypidfile=”$result”
start(){
    [-x $exec] || exit 5
    # check to see if it’s already running
    RESPONSE=`/usr/local/mysql/bin/mysqladmin–socket=”$socketfile” –user=UNKNOWN_MYSQL_USER ping 2>&1`
    if [$? = 0]; then
        # already running, do nothing
        action $”Starting $prog: “/bin/true
        ret=0
    elif echo “$RESPONSE” | grep -q”Access denied for user”
    then
        # already running, do nothing
        action $”Starting $prog: “/bin/true
        ret=0
    else
        # prepare for start
        touch “$errlogfile”
        chown mysql:mysql”$errlogfile”
        chmod 0640 “$errlogfile”
        [-x /sbin/restorecon] &&/sbin/restorecon “$errlogfile”
        if [! -d “$datadir/mysql”]; then
            # First, make sure $datadir isthere with correct permissions
            if [! -e “$datadir” -a !-h “$datadir”]
            then
                mkdir -p “$datadir”|| exit 1
          fi
            chown mysql:mysql”$datadir”
            chmod 0755 “$datadir”
            [-x /sbin/restorecon] &&/sbin/restorecon “$datadir”
            # Now create the database
            action $”Initializing MySQLdatabase: ” /usr/local/mysql/scripts/mysql_install_db–datadir=”$datadir” –user=mysql
            ret=$?
            chown -R mysql:mysql”$datadir”
            if [$ret -ne 0] ; then
                return $ret
            fi
        fi
        chown mysql:mysql “$datadir”
        chmod 0755 “$datadir”
        # Pass all the options determinedabove, to ensure consistent behavior.
        # In many cases mysqld_safe wouldarrive at the same conclusions anyway
        # but we need to be sure.  (An exception is that we don’t force the
        # log-error setting, since this scriptdoesn’t really depend on that,
        # and some users might prefer toconfigure logging to syslog.)
        # Note: set –basedir to prevent probesthat might trigger SELinux
        # alarms, per bug #547485
        $exec  –datadir=”$datadir” –socket=”$socketfile” \
              –pid-file=”$mypidfile” \
                –basedir=/usr/local/mysql–user=mysql >/dev/null 2>&1 &
        safe_pid=$!
        # Spin for a maximum of N secondswaiting for the server to come up;
        # exit the loop immediately ifmysqld_safe process disappears.
        # Rather than assuming we know a validusername, accept an “access
        # denied” response as meaning theserver is functioning.
        ret=0
        TIMEOUT=”$STARTTIMEOUT”
        while [$TIMEOUT -gt 0]; do
            RESPONSE=`/usr/bin/mysqladmin–socket=”$socketfile” –user=UNKNOWN_MYSQL_USER ping 2>&1`&& break
            echo “$RESPONSE” | grep-q “Access denied for user” && break
            if ! /bin/kill -0 $safe_pid2>/dev/null; then
                echo “MySQL Daemon failedto start.”
                ret=1
                break
            fi
            sleep 1
            let TIMEOUT=${TIMEOUT}-1
        done
        if [$TIMEOUT -eq 0]; then
            echo “Timeout error occurredtrying to start MySQL Daemon.”
            ret=1
        fi
        if [$ret -eq 0]; then
            action $”Starting $prog:” /bin/true
            touch $lockfile
        else
            action $”Starting $prog:” /bin/false
        fi
    fi
    return $ret
}
stop(){
        if [! -f “$mypidfile”];then
            # not running; per LSB standardsthis is “ok”
            action $”Stopping $prog:” /bin/true
            return 0
        fi
        MYSQLPID=`cat “$mypidfile”`
        if [-n “$MYSQLPID”]; then
            /bin/kill “$MYSQLPID”>/dev/null 2>&1
            ret=$?
            if [$ret -eq 0]; then
              TIMEOUT=”$STOPTIMEOUT”
                while [$TIMEOUT -gt 0]; do
                    /bin/kill -0″$MYSQLPID” >/dev/null 2>&1 || break
                    sleep 1
                    let TIMEOUT=${TIMEOUT}-1
                done
                if [$TIMEOUT -eq 0]; then
                    echo “Timeout erroroccurred trying to stop MySQL Daemon.”
                    ret=1
                    action $”Stopping$prog: ” /bin/false
                else
                    rm -f $lockfile
                    rm -f”$socketfile”
                    action $”Stopping$prog: ” /bin/true
                fi
            else
                action $”Stopping $prog:” /bin/false
            fi
        else
            # failed to read pidfile, probablyinsufficient permissions
            action $”Stopping $prog:” /bin/false
            ret=4
        fi
        return $ret
}
restart(){
    stop
    start
}
condrestart(){
    [-e $lockfile] && restart || :
}
# See how we were called.
case “$1” in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status -p “$mypidfile” $prog
    ;;
  restart)
    restart
    ;;
  condrestart|try-restart)
    condrestart
    ;;
  reload)
    exit 3
    ;;
  force-reload)
    restart
    ;;
  *)
    echo $”Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload}”
    exit 2
esac
exit $?

Tengine 的详细介绍:请点这里
Tengine 的下载地址:请点这里

相关阅读

CentOS 6.4 制作 Tengine 的 rpm 包 http://www.linuxidc.com/Linux/2013-12/93786.htm

Tengine 动态开启模块试用 http://www.linuxidc.com/Linux/2012-12/75849.htm

CentOS 6.3 用 ICC 编译 PHP5.4.8+Percona5.5.27+Tengine1.4.1 http://www.linuxidc.com/Linux/2012-12/76636.htm

基于淘宝 Tengine 和 Scribe 的 WEB 日志收集方案 http://www.linuxidc.com/Linux/2012-02/52997.htm

基于 Tengine 部署 LNMP 环境 http://www.linuxidc.com/Linux/2014-01/95148.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计19933字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中