zoukankan      html  css  js  c++  java
  • Centos5.564位安装nginx0.8.54+php5.3.4+mysql5.5.8+memcache2.2.6(转)

    #首先获取相关软件的源码

    mkdir -p /www/software
    cd /www/software
    wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
    wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
    wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz
    wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
    wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"
    wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
    wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
    wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.8.tar.gz
    wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.54.tar.gz
    wget http://www.php.net/get/php-5.3.4.tar.gz/from/this/mirror

    http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

    wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz #32位系统
    wget http://projects.unbit.it/downloads/uwsgi-0.9.6.5.tar.gz
    wget http://www.djangoproject.com/download/1.2.3/tarball/
    wget http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmysql-python%2F&ts=1291978093&use_mirror=nchc
    wget http://www.python.org/ftp/python/2.7/Python-2.7.tgz
    wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
    wget ftp://invisible-island.net/ncurses/ncurses-5.7.tar.gz
    wget http://labs.frickle.com/files/ngx_cache_purge-1.2.tar.gz
    wget http://labs.frickle.com/files/ngx_slowfs_cache-1.5.tar.gz
    wget http://nginx.org/download/nginx-0.8.54.tar.gz
    wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
    wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
    wget http://pecl.php.net/get/imagick-3.0.1.tgz
    wget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.6.6-5.tar.gz
    wget http://pecl.php.net/get/memcache-2.2.6.tgz
    wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
    wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz

    #添加WWW用户以及相应的权限,并且建立相应的文件夹

    /usr/sbin/groupadd www
    /usr/sbin/useradd -g www www
    mkdir -p /www/temp/logs/
    mkdir -p /www/temp/logs/
    mkdir -p /www/temp/eaccelerator/
    mkdir -p /www/temp/logs/
    mkdir -p /www/temp/fastcgi_cache
    mkdir -p /www/temp/fastcgi_temp
    mkdir -p /www/temp/gzip
    mkdir -p /www/temp/mysql/binlog
    mkdir -p /www/temp/mysql/relaylog
    mkdir -p /www/temp/nginx_cache
    mkdir -p /www/temp/proxy_cahe
    mkdir -p /www/temp/proxy_temp
    mkdir -p /www/temp/scgi_temp
    mkdir -p /www/temp/sessiondata
    mkdir -p /www/temp/uploadtemp
    mkdir -p /www/temp/uwsgi_temp
    mkdir -p /www/temp/client_body_temp
    mkdir -p /www/temp/cookiedata
    chmod +w /www/temp
    chown -R www:www /www/temp
    chown -R www:www /www

    #centos 5.5 64位 获取更新以及安装相应软件的依赖库

    yum -y update
    sudo -s
    LANG=C
    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libevent libevent-devel samba automake fonts-chinese scim-chewing scim-pinyin scim-tables-chinese vim-minimal sendmail libtool libtool-libs kernel-devel gettext gettext-devel libaio libaio-devel

    #centos 5.5 64位 编译安装 PHP 5.3.4字符集转换库 libiconv-1.13.1
    cd /www/software
    tar zxvf libiconv-1.13.1.tar.gz
    cd libiconv-1.13.1/
    ./configure --prefix=/usr/local
    make&&make install
    cd ../

    #centos 5.5 64位 编译安装 PHP 5.3.4 libmcrypt-2.5.8库
    tar zxvf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8/
    ./configure
    make&&make install
    /sbin/ldconfig
    cd libltdl/
    ./configure --enable-ltdl-install
    make&&make install
    cd http://www.cnblogs.com/

    #centos 5.5 64位 编译安装 PHP 5.3.4 mhash-0.9.9.9库
    tar zxvf mhash-0.9.9.9.tar.gz
    cd mhash-0.9.9.9/
    ./configure
    make&&make install
    cd ../

    #centos 5.5 64位 编译安装 PHP 5.3.4 libevent-1.4.14b-stable库
    tar zxvf libevent-1.4.14b-stable.tar.gz
    cd libevent-1.4.14b-stable
    ./configure --prefix=/usr
    make
    make install
    cd ..//

    #CENTOS 5.5 64位 建立相关库的软连接
    ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
    ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
    ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
    ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
    ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
    ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
    ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
    ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
    ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
    ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
    ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2
    ldconfig

    #如果是CENTOS 5.5 32位的话,就是
    ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
    ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
    ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
    ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
    ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
    ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
    ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
    ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
    ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
    ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
    ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
    ldconfig

    #CENTOS 5.5 64位 编译安装PHP加密扩展库mcrypt-2.6.8
    tar zxvf mcrypt-2.6.8.tar.gz
    cd mcrypt-2.6.8/
    /sbin/ldconfig
    ./configure
    make&&make install
    cd ../

    #CENTOS 5.5 64位 编译安装 webbench-1.5网站压力测试工具
    mkdir -p /usr/local/man
    mkdir -p /usr/local/man/man1
    tar zxvf webbench-1.5.tar.gz
    cd webbench-1.5
    make install
    install -s webbench /usr/local/bin
    install -m 644 webbench.1 /usr/local/man/man1
    install -d /usr/local/share/doc/webbench
    install -m 644 debian/copyright /usr/local/share
    cd ../

    #CENTOS 5.5 64位 编译安装 GD库(让PHP支持GIF,PNG,JPEG)
    tar zxvf jpegsrc.v8b.tar.gz
    cd jpeg-8b/
    ./configure
    make&&make install
    cd ../

    #CENTOS 5.5 64位 编译安装 gd-2.0.35 PHPGD库
    tar -zxf gd-2.0.35.tar.gz
    cd gd-2.0.35/
    ./configure --prefix=/usr/local --with-libiconv-prefix=/usr/local --with-png=/usr/local --with-freetype=/usr/local --with-jpeg=/usr/local
    make&&make install
    cd ../

    #CENTOS 5.5 64位 编译安装 cmake-2.8.3编译配置工具
    tar -zxvf cmake-2.8.3.tar.gz
    cd cmake-2.8.3
    ./configure --prefix=/usr
    make&&make install
    cd ../

    #CENTOS 5.5 64位 编译安装 mysql-5.5.8
    cd /www/software
    /usr/sbin/groupadd mysql
    /usr/sbin/useradd -g mysql mysql
    tar zxvf mysql-5.5.8.tar.gz
    cd mysql-5.5.8
    cmake . -DCMAKE_INSTALL_PREFIX=/www/webserver/mysql -DMYSQL_DATADIR=/www/webserver/mysql/data -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/www/webserver/mysql/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=on
    make&&make install
    /www/webserver/mysql/scripts/mysql_install_db --basedir=/www/webserver/mysql --datadir=/www/webserver/mysql/data --user=mysql
    #复制mysql.server 到/etc/init.d/做为服务启动
    cp support-files/mysql.server /etc/init.d/mysqld
    #设置软链接防止libmysqlclient.so.16: cannot open shared object file 的错误
    ln -s /www/webserver/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
    #这是胜于64位系统下的MYSQL客户端软链接
    ln -s /www/webserver/mysql/lib/libmysqlclient.so.16 /usr/lib64/libmysqlclient.so.16

    #替换MYSQL自启动脚本的MYSQL基本路径
    sed -i "s#basedir=#basedir=/www/webserver/mysql#g" /etc/init.d/mysqld
    cd ../
    #然后查看一下,/etc/init.d/mysqld 是否正确
    more /etc/init.d/mysqld
    #注意不要把这一段文本复制到终端哦,只是查看配置是否正确而矣
    #!/bin/sh
    # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
    # This file is public domain and comes with NO WARRANTY of any kind

    # MySQL daemon start/stop script.

    # Usually this is put in /etc/init.d (at least on machines SYSV R4 based
    # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
    # When this is done the mysql server will be started when the machine is
    # started and shut down when the systems goes down.

    # Comments to support chkconfig on RedHat Linux
    # chkconfig: 2345 64 36
    # description: A very fast and reliable SQL database engine.

    # Comments to support LSB init script conventions
    ### BEGIN INIT INFO
    # Provides: mysql
    # Required-Start: $local_fs $network $remote_fs
    # Should-Start: ypbind nscd ldap ntpd xntpd
    # Required-Stop: $local_fs $network $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: start and stop MySQL
    # Description: MySQL is a very fast and reliable SQL database engine.
    ### END INIT INFO

    # If you install MySQL on some other places than ., then you
    # have to do one of the following things for this script to work:
    #
    # - Run this script from within the MySQL installation directory
    # - Create a /etc/my.cnf file with the following information:
    # [mysqld]
    # basedir=/www/webserver/mysql/www/webserver/mysql # - Add the above to any other configuration file (for example ~/.my.ini)
    # and copy my_print_defaults to /usr/bin
    # - Add the path to the mysql-installation-directory to the basedir variable
    # below.
    #
    # If you want to affect other MySQL variables, you should make your changes
    # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

    # If you change base dir, you must also change datadir. These may get
    # overwritten by settings in the MySQL configuration files.

    basedir=/www/webserver/mysql
    datadir=

    # Default value, in seconds, afterwhich the script should timeout waiting
    # for server start.
    # Value here is overriden by value in my.cnf.
    # 0 means don't wait at all
    # Negative numbers mean to wait indefinitely
    service_startup_timeout=900

    # Lock directory for RedHat / SuSE.
    lockdir='/var/lock/subsys'
    lock_file_path="$lockdir/mysql"

    # The following variables are only set for letting mysql.server find things.

    # Set some defaults
    mysqld_pid_file_path=
    if test -z "$basedir"
    then
    basedir=/www/webserver/mysql.
    bindir=./bin
    if test -z "$datadir"
    then
    datadir=/www/webserver/mysql/data
    fi
    sbindir=./bin
    libexecdir=./bin
    else
    bindir="$basedir/bin"
    if test -z "$datadir"
    then
    datadir="$basedir/data"
    fi
    sbindir="$basedir/sbin"
    libexecdir="$basedir/libexec"
    fi

    # datadir_set is used to determine if datadir was set (and so should be
    # *not* set inside of the --basedir=/www/webserver/mysql/www/webserver/mysql handler.)
    datadir_set=

    #
    # Use LSB init script functions for printing messages, if possible
    #
    lsb_functions="/lib/lsb/init-functions"
    if test -f $lsb_functions ; then
    . $lsb_functions
    else
    log_success_msg()
    {
    echo " SUCCESS! $@"
    }
    log_failure_msg()
    {
    echo " ERROR! $@"
    }
    fi

    PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
    export PATH

    mode=$1 # start or stop

    [ $# -ge 1 ] && shift

    other_args="$*" # uncommon, but needed when called from an RPM upgrade action
    # Expected: "--skip-networking --skip-grant-tables"
    # They are not checked here, intentionally, as it is the resposibility
    # of the "spec" file author to give correct arguments only.

    case `echo "testing\c"`,`echo -n testing` in
    *c*,-n*) echo_n= echo_c= ;;
    *c*,*) echo_n=-n echo_c= ;;
    *) echo_n= echo_c='\c' ;;
    esac

    parse_server_arguments() {
    for arg do
    case "$arg" in
    --basedir=/www/webserver/mysql/www/webserver/mysql*) basedir=/www/webserver/mysql/www/webserver/mysql`echo "$arg" | sed -e 's/^[^=]*=//'`
    bindir="$basedir/bin"
    if test -z "$datadir_set"; then
    datadir="$basedir/data"
    fi
    sbindir="$basedir/sbin"
    libexecdir="$basedir/libexec"
    ;;
    --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
    datadir_set=1
    ;;
    --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
    --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
    esac
    done
    }

    wait_for_pid () {
    verb="$1" # created | removed
    pid="$2" # process ID of the program operating on the pid-file
    pid_file_path="$3" # path to the PID file.

    i=0
    avoid_race_condition="by checking again"

    while test $i -ne $service_startup_timeout ; do

    case "$verb" in
    'created')
    # wait for a PID-file to pop into existence.
    test -s "$pid_file_path" && i='' && break
    ;;
    'removed')
    # wait for this PID-file to disappear
    test ! -s "$pid_file_path" && i='' && break
    ;;
    *)
    echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
    exit 1
    ;;
    esac

    # if server isn't running, then pid-file will never be updated
    if test -n "$pid"; then
    if kill -0 "$pid" 2>/dev/null; then
    : # the server still runs
    else
    # The server may have exited between the last pid-file check and now.
    if test -n "$avoid_race_condition"; then
    avoid_race_condition=""
    continue # Check again.
    fi

    # there's nothing that will affect the file.
    log_failure_msg "The server quit without updating PID file ($pid_file_path)."
    return 1 # not waiting any more.
    fi
    fi

    echo $echo_n ".$echo_c"
    i=`expr $i + 1`
    sleep 1

    done

    if test -z "$i" ; then
    log_success_msg
    return 0
    else
    log_failure_msg
    return 1
    fi
    }

    # Get arguments from the my.cnf file,
    # the only group, which is read from now on is [mysqld]
    if test -x ./bin/my_print_defaults
    then
    print_defaults="./bin/my_print_defaults"
    elif test -x $bindir/my_print_defaults
    then
    print_defaults="$bindir/my_print_defaults"
    elif test -x $bindir/mysql_print_defaults
    then
    print_defaults="$bindir/mysql_print_defaults"
    else
    # Try to find basedir in /etc/my.cnf
    conf=/etc/my.cnf
    print_defaults=
    if test -r $conf
    then
    subpat='^[^=]*basedir[^=]*=\(.*\)$'
    dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
    for d in $dirs
    do
    d=`echo $d | sed -e 's/[ ]//g'`
    if test -x "$d/bin/my_print_defaults"
    then
    print_defaults="$d/bin/my_print_defaults"
    break
    fi
    if test -x "$d/bin/mysql_print_defaults"
    then
    print_defaults="$d/bin/mysql_print_defaults"
    break
    fi
    done
    fi

    # Hope it's in the PATH ... but I doubt it
    test -z "$print_defaults" && print_defaults="my_print_defaults"
    fi

    #
    # Read defaults file from 'basedir'. If there is no defaults file there
    # check if it's in the old (depricated) place (datadir) and read it from there
    #

    extra_args=""
    if test -r "$basedir/my.cnf"
    then
    extra_args="-e $basedir/my.cnf"
    else
    if test -r "$datadir/my.cnf"
    then
    extra_args="-e $datadir/my.cnf"
    fi
    fi

    parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`

    #
    # Set pid file if not given
    #
    if test -z "$mysqld_pid_file_path"
    then
    mysqld_pid_file_path=$datadir/`hostname`.pid
    else
    case "$mysqld_pid_file_path" in
    /* ) ;;
    * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
    esac
    fi

    case "$mode" in
    'start')
    # Start daemon

    # Safeguard (relative paths, core dumps..)
    cd $basedir

    echo $echo_n "Starting MySQL"
    if test -x $bindir/mysqld_safe
    then
    # Give extra arguments to mysqld with the my.cnf file. This script
    # may be overwritten at next upgrade.
    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?

    # Make lock for RedHat / SuSE
    if test -w "$lockdir"
    then
    touch "$lock_file_path"
    fi

    exit $return_value
    else
    log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
    fi
    ;;

    'stop')
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.

    if test -s "$mysqld_pid_file_path"
    then
    mysqld_pid=`cat "$mysqld_pid_file_path"`

    if (kill -0 $mysqld_pid 2>/dev/null)
    then
    echo $echo_n "Shutting down MySQL"
    kill $mysqld_pid
    # mysqld should remove the pid file when it exits, so wait for it.
    wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
    else
    log_failure_msg "MySQL server process #$mysqld_pid is not running!"
    rm "$mysqld_pid_file_path"
    fi

    # Delete lock for RedHat / SuSE
    if test -f "$lock_file_path"
    then
    rm -f "$lock_file_path"
    fi
    exit $return_value
    else
    log_failure_msg "MySQL server PID file could not be found!"
    fi
    ;;

    'restart')
    # Stop the service and regardless of whether it was
    # running or not, start it again.
    if $0 stop $other_args; then
    $0 start $other_args
    else
    log_failure_msg "Failed to stop running server, so refusing to try to start."
    exit 1
    fi
    ;;

    'reload'|'force-reload')
    if test -s "$mysqld_pid_file_path" ; then
    read mysqld_pid < "$mysqld_pid_file_path"
    kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
    touch "$mysqld_pid_file_path"
    else
    log_failure_msg "MySQL PID file could not be found!"
    exit 1
    fi
    ;;
    'status')
    # First, check to see if pid file exists
    if test -s "$mysqld_pid_file_path" ; then
    read mysqld_pid < "$mysqld_pid_file_path"
    if kill -0 $mysqld_pid 2>/dev/null ; then
    log_success_msg "MySQL running ($mysqld_pid)"
    exit 0
    else
    log_failure_msg "MySQL is not running, but PID file exists"
    exit 1
    fi
    else
    # Try to find appropriate mysqld process
    mysqld_pid=`pidof $libexecdir/mysqld`
    if test -z $mysqld_pid ; then
    if test -f "$lock_file_path" ; then
    log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
    exit 2
    fi
    log_failure_msg "MySQL is not running"
    exit 3
    else
    log_failure_msg "MySQL is running but PID file could not be found"
    exit 4
    fi
    fi
    ;;
    *)
    # usage
    basename=`basename "$0"`
    echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
    exit 1
    ;;
    esac

    exit 0

    #映射MYSQL 5.5.8 为系统环境

    chmod +w /www/webserver/mysql
    chmod +x /www/webserver/mysql
    chown -R mysql:mysql /www/webserver/mysql
    chown -R mysql:mysql /www/webserver/mysql/data
    chkconfig --levels 235 mysqld on
    chkconfig --add mysqld
    chmod 755 /etc/init.d/mysqld
    chmod 777 -R /www/temp/logs
    chown -R mysql:mysql /tmp/mysql.sock

    #配置库文件搜索路径
    echo "/www/webserver/mysql/lib/mysql" >> /etc/ld.so.conf
    ldconfig

    #/www/webserver/mysql/my.cnf 添加MYSQL的配置文件

    cat >>/www/webserver/mysql/my.cnf <
    [client]
    character-set-server = utf8
    port = 3306
    socket = /tmp/mysql.sock

    [mysqld]
    character-set-server = utf8
    replicate-ignore-db = mysql
    replicate-ignore-db = test
    replicate-ignore-db = information_schema
    user = mysql
    port = 3306
    socket = /tmp/mysql.sock
    basedir = /www/webserver/mysql
    datadir = /www/webserver/mysql/data
    log-error = /www/temp/logs/mysql_error.log
    pid-file = /www/temp/logs/mysql.pid
    open_files_limit = 10240
    back_log = 600
    max_connections = 5000
    max_connect_errors = 6000
    table_cache = 614
    external-locking = FALSE
    max_allowed_packet = 32M
    sort_buffer_size = 1M
    join_buffer_size = 1M
    thread_cache_size = 300
    #thread_concurrency = 8
    query_cache_size = 512M
    query_cache_limit = 2M
    query_cache_min_res_unit = 2k
    default-storage-engine = MyISAM
    thread_stack = 192K
    transaction_isolation = READ-COMMITTED
    tmp_table_size = 246M
    max_heap_table_size = 246M
    long_query_time = 3
    log-slave-updates
    log-bin = /www/temp/mysql/binlog
    binlog_cache_size = 4M
    binlog_format = MIXED
    max_binlog_cache_size = 8M
    max_binlog_size = 1G
    relay-log-index = /www/temp/mysql/relaylog
    relay-log-info-file = /www/temp/mysql/relaylog
    relay-log = /www/temp/mysql/relaylog
    expire_logs_days = 30
    key_buffer_size = 256M
    read_buffer_size = 1M
    read_rnd_buffer_size = 16M
    bulk_insert_buffer_size = 64M
    myisam_sort_buffer_size = 128M
    myisam_max_sort_file_size = 10G
    myisam_repair_threads = 1
    myisam_recover

    interactive_timeout = 120
    wait_timeout = 120

    skip-name-resolve
    #master-connect-retry = 10
    slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

    #master-host = 192.168.1.2
    #master-user = username
    #master-password = password
    #master-port = 3306

    server-id = 1

    innodb_additional_mem_pool_size = 16M
    innodb_buffer_pool_size = 512M
    innodb_data_file_path = ibdata1:256M:autoextend
    innodb_file_io_threads = 4
    innodb_thread_concurrency = 8
    innodb_flush_log_at_trx_commit = 2
    innodb_log_buffer_size = 16M
    innodb_log_file_size = 128M
    innodb_log_files_in_group = 3
    innodb_max_dirty_pages_pct = 90
    innodb_lock_wait_timeout = 120
    innodb_file_per_table = 0

    #log-slow-queries = /www/temp/logs/slow.log
    #long_query_time = 10

    [mysqldump]
    quick
    max_allowed_packet = 32M
    EOF

    #添加MYSQL的路径为系统环境变

    drop   user  root@127.0.0.1; 

    drop   user  root@localhost.localdomain; 

    drop   user   '' @localhost.localdomain; 

    drop   user   '' @localhost; 

    drop   user   'root' @ '::1' ;
    drop user '' @ '%' ;

    exit

    tar zxvf php-5.3.4.tar.gz
    cd php-5.3.4
    ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --disable-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-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear
    mkdir /usr/local/webserver/mysql/include/mysql
    chown -R mysql:mysql /usr/local/webserver/mysql/include/mysql
    ln -s /usr/local/webserver/mysql/include/* /usr/local/webserver/mysql/include/mysql/

    vim /etc/ld.so.conf

    添加/usr/local/webserver/mysql/lib/

    ldconfig

    make ZEND_EXTRA_LIBS='-liconv'

    make install
    cp php.ini-production /usr/local/webserver/php/etc/php.ini
    cd ../
    tar zxvf memcache-2.2.6.tgz
    cd memcache-2.2.6
    /usr/local/webserver/php/bin/phpize
    ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
    make
    make install
    cd ../
    tar jxvf eaccelerator-0.9.6.1.tar.bz2
    cd eaccelerator-0.9.6.1/
    /usr/local/webserver/php/bin/phpize
    ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
    make
    make install
    cd ../
    vim /usr/local/webserver/php/etc/php.ini


    extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/"
    extension = "memcache.so"

    always_populate_raw_post_data=On
    [eaccelerator]
    zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
    eaccelerator.shm_size="64"
    eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="3600"
    eaccelerator.shm_prune_period="3600"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"


    mkdir -p /usr/local/webserver/eaccelerator_cache
    /usr/sbin/groupadd www
    /usr/sbin/useradd -g www www
    mkdir -p /data/htdocs/bbs
    mkdir -p /data/htdocs/ad
    chmod +w /data/htdocs/bbs
    chmod +w /data/htdocs/ad
    chown -R www:www /data/htdocs/ad
    chown -R www:www /data/htdocs/bbs
    cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
    vim /usr/local/webserver/php/etc/php-fpm.conf


    [global]
    pid = /usr/local/webserver/php/logs/php-fpm.pid
    error_log = /usr/local/webserver/php/logs/php-fpm.log
    log_level = notice
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m
    process_control_timeout = 5s
    daemonize = yes
    [www]
    listen = 127.0.0.1:9000
    listen.backlog = -1
    listen.allowed_clients = 127.0.0.1
    user = www
    group = www
    pm = static
    pm.max_children = 64
    pm.start_servers = 20
    pm.min_spare_servers = 5
    pm.max_spare_servers = 35
    pm.max_requests = 1024

    request_terminate_timeout = 0s
    request_slowlog_timeout = 0s
    slowlog = logs/slow.log
    rlimit_files = 65535
    rlimit_core = 0
    chroot =
    chdir =
    catch_workers_output = yes
    env[HOSTNAME] = $HOSTNAME
    env[PATH] = /usr/local/bin:/usr/bin:/bin
    env[TMP] = /tmp
    env[TMPDIR] = /tmp
    env[TEMP] = /tmp


    /usr/local/webserver/php/sbin/php-fpm
    tar zxvf pcre-8.11.tar.gz
    cd pcre-8.11/
    ./configure
    make && make install
    cd ../
    tar zxvf nginx-0.8.54.tar.gz
    cd nginx-0.8.54/
    ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
    make && make install
    cd ../
    mkdir -p /data/logs/
    chmod +w /data/logs/
    chown -R www:www /data/logs/
    rm -f /usr/local/webserver/nginx/conf/nginx.conf
    vim /usr/local/webserver/nginx/conf/nginx.conf


    user www www;
    worker_processes 6;
    error_log /data/logs/nginx_error.log crit;
    pid /usr/local/webserver/nginx/nginx.pid;
    worker_rlimit_nofile 65535;

    events {
      use epoll;
      worker_connections 65535;
    }

    http {
      include mime.types;
      default_type application/octet-stream;

      server_names_hash_bucket_size 128;
      client_header_buffer_size 32k;
      large_client_header_buffers 4 32k;
      client_max_body_size 8m;

      sendfile on;
      tcp_nopush on;

      keepalive_timeout 60;

      tcp_nodelay on;

      fastcgi_connect_timeout 300;
      fastcgi_send_timeout 300;
      fastcgi_read_timeout 300;
      fastcgi_buffer_size 64k;
      fastcgi_buffers 4 64k;
      fastcgi_busy_buffers_size 128k;
      fastcgi_temp_file_write_size 128k;

      gzip on;
      gzip_min_length 1k;
      gzip_buffers 4 16k;
      gzip_http_version 1.0;
      gzip_comp_level 2;
      gzip_types text/plain application/x-javascript text/css application/xml;
      gzip_vary on;

      server {
        listen 80;
        server_name bbs.test.com;
        index index.html index.htm index.php;
        root /data/htdocs/bbs;

        location ~ .*\.(php|php5)?$ {
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_index index.php;
          include fcgi.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
          expires 7d;
        }  

        log_format access  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" $http_x_forwarded_for';
        access_log /data/logs/access_bbs.log access;
      }

      server {
        listen 80;
        server_name ad.test.com;
        index index.php;
        root /data/htdocs/ad;

        location ~ .*\.(php|php5)?$ {      
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          include fcgi.conf;
        }

        log_format  adlogs  '$remote_addr - $remote_user [$time_local] "$request" '
                   '$status $body_bytes_sent "$http_referer" '
                   '"$http_user_agent" $http_x_forwarded_for';
        access_log  /data/logs/access_ad.log adlogs;
      }

      server
      {
        listen  80;
        server_name  status.3j3w.com;

        location / {
          stub_status on;
          access_log off;
        }
      }
    }


    vim /usr/local/webserver/nginx/conf/fcgi.conf

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx;

    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;

    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;


    ulimit -SHn 65535
    /usr/local/webserver/nginx/sbin/nginx
    vim /etc/rc.local

    ulimit -SHn 65535
    /usr/local/webserver/php/sbin/php-fpm
    /usr/local/webserver/nginx/sbin/nginx

    vim /etc/sysctl.conf


    # Add
    net.ipv4.tcp_max_syn_backlog = 65536
    net.core.netdev_max_backlog =  32768
    net.core.somaxconn = 32768

    net.core.wmem_default = 8388608
    net.core.rmem_default = 8388608
    net.core.rmem_max = 16777216
    net.core.wmem_max = 16777216

    net.ipv4.tcp_timestamps = 0
    net.ipv4.tcp_synack_retries = 2
    net.ipv4.tcp_syn_retries = 2

    net.ipv4.tcp_tw_recycle = 1
    #net.ipv4.tcp_tw_len = 1
    net.ipv4.tcp_tw_reuse = 1

    net.ipv4.tcp_mem = 94500000 915000000 927000000
    net.ipv4.tcp_max_orphans = 3276800

    #net.ipv4.tcp_fin_timeout = 30
    #net.ipv4.tcp_keepalive_time = 120
    net.ipv4.ip_local_port_range = 1024  65535


    /sbin/sysctl -p
    vim /usr/local/webserver/nginx/sbin/cut_nginx_log.sh


    #!/bin/bash
    # This script run at 00:00

    # The Nginx logs path
    logs_path="/data/logs/"

    mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
    mv ${logs_path}access_bbs.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_bbs_$(date -d "yesterday" +"%Y%m%d").log
    mv ${logs_path}access_ad.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_ad_$(date -d "yesterday" +"%Y%m%d").log
    kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`


    crontab -e

    00 00 * * * /bin/bash  /usr/local/webserver/nginx/sbin/cut_nginx_log.sh



    SIGINT, SIGTERM 立刻终止
    SIGQUIT 平滑终止
    SIGUSR1 重新打开日志文件
    SIGUSR2 平滑重载所有worker进程并重新载入配置和二进制模块

    示例:
    php-fpm 关闭:
    kill -SIGINT `cat /usr/local/webserver/php/logs/php-fpm.pid`
    php-fpm 重新打开日志文件:
    kill -SIGUSR1 `cat /usr/local/webserver/php/logs/php-fpm.pid`
    php-fpm 重启:
    kill -SIGUSR2 `cat /usr/local/webserver/php/logs/php-fpm.pid`

  • 相关阅读:
    java IO
    免费的编程中文书籍索引-转
    js两种定义函数、继承方式及区别
    为什么这样写js:(function ($) { })(jQuery);
    Cannot open connection 解决办法
    dos下mysql登陆
    spring-AOP-1
    el表达式
    设计模式——"simple Factory"
    软件生产性控制
  • 原文地址:https://www.cnblogs.com/vicowong/p/1946220.html
Copyright © 2011-2022 走看看