상용 환경 설치

15243 단어 APICloud
node 컴 파일 설치 다운로드 주소:http://nodejs.org/dist/v0.12.2/node-v0.12.2.tar.gz
컴 파일 설치:
./configure --prefix=/usr/local/nodejs && make &&make install

시스템 환경 설정:
echo "#set nodejs environment
export PATH=\$PATH:/usr/local/nodejs/bin" >>/etc/profile && source /etc/profile

nginx 컴 파일 설치
다운로드 주소:http://nginx.org/download/nginx-1.9.11.tar.gz
컴 파일 설치:
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel opensslopenssl-devel pcre-devel gd-*

groupadd-r nginx && useradd -s /sbin/nologin -g nginx -r nginx

./configure--prefix=/usr/local/nginx --lock-path=/usr/local/nginx/nginx.lock --user=nginx--group=nginx --with-http_ssl_module --with-http_flv_module--with-http_stub_status_module --with-http_gzip_static_module--http-client-body-temp-path=/usr/local/nginx/client/--http-proxy-temp-path=/usr/local/nginx/proxy/--http-fastcgi-temp-path=/usr/local/nginx/fcgi/--http-uwsgi-temp-path=/usr/local/nginx/uwsgi--http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre --with-file-aio--with-http_image_filter_module && make && make install

시작 스 크 립 트 설정    
vim /etc/init.d/nginx chmod +x /etc/init.d/nginx  chkconfig nginx on
#!/bin/bash
#
# Startup script for Nginx - this script starts 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: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
 
lockfile=/var/lock/subsys/nginx
 
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 $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
 
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

3. mysql 컴 파일 설치
   다운로드 주소:http://down1.chinaunix.net/distfiles/cmake-2.8.10.2.tar.gz 
        http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.28.tar.gz   
   cmake 컴 파일 설치:   
     ./configure --prefix=/usr/local/cmake && make && make install 
     echo "#set cmake environment
export PATH=\$PATH:/usr/local/cmake/bin" >> /etc/profile && source /etc/profile

   mysql 컴 파일 설치:   
     groupadd mysql && useradd -r -g mysql -s /etc/nologin mysql
     
     cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/home/mysql/var/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci && make && make install
     echo "#set mysql environment
export PATH=\$PATH:/usr/sbin/:/usr/local/mysql/bin" >> /etc/profile && source /etc/profile

   mysql 데이터베이스 초기 화: 
     /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql --default-storage-engine=MyISAM

   시작 스 크 립 트 설정:
     cp /usr/local/src/mysql-5.6.28/support-files/mysql.server /etc/init.d/mysql
     chmod +x /etc/init.d/mysql
     chkconfig --add mysql && chkconfig mysql on

4. redis 컴 파일 설치:
    다운로드 주소:
        http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz 
        http://download.redis.io/releases/redis-3.0.0.tar.gz
    tcl 컴 파일 설치: 
     tar xf /usr/local/src/tcl8.6.1-src.tar.gz -C /usr/local/
     cd /usr/local/tcl8.6.1/unix/ && ./configure && make && make install

    redis 컴 파일 설치:   
     tar xf /usr/local/src/redis-3.0.0.tar.gz -C /usr/local/src
     cd /usr/local/src/redis-3.0.0 && make test && make PREFIX=/usr/local/redis install

   시작 스 크 립 트 설정: 
     vim /etc/init.d/redis-6380   chmod +x /etc/init.d/redis-6380 chkcofnig redis-6380 on
          mkdir -p /home/redis/db && mkdir -p /home/redis/log && mkdir -p /home/redis/var
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig:   - 85 15
# description:  Redis for uzAll session
# processname: redis-server-6379

REDISPORT=6380
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/home/redis/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"

case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting Redis server..."
                $EXEC $CONF
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

    설정 파일: / etc / redis / 6380. conf
daemonize yes
pidfile /home/redis/redis_6380.pid
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel warning
logfile /home/redis/log/redis_6380.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /home/redis/data/6380
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

 
5. python 2.7.8 컴 파일 설치:
yum -y install zlib zlib-devel openssl-devel gcc python-devel
1.python 2.7.8  
cd /usr/local/src/python && tar xf Python-2.7.8.tgz && cd Python-2.7.8
./configure --prefix=/usr/local/python2.7.8 && make && make install
mv /usr/bin/python /usr/bin/python_old && ln -s /usr/local/python2.7.8/bin/python2.7 /usr/bin/python
2.    setuptools pip
tar xf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py build  
python setup.py install 
tar xf pip-6.1.1.tar.gz
cd pip-6.1.1
python setup.py build  
python setup.py install
vim /etc/profile
==========================
#set python_pip environment
export PATH=$PATH:/usr/local/python2.7.8/bin
==========================
(     CentOS,   python2.6,    ,        2.7.9,      ,    pip,    : No module named 'pip._vendor.requests'       ,   stackoverflow     ,             ssl       。   yum install openssl-devel,      python2.7.9,    。...)
whereis pip   pip     
3.    MySQLdb (  :http://www.jb51.net/article/60631.htm)
unzip MySQLdb1-master.zip
cd MySQLdb1-master
#vi site.cfg
================================
threadsafe = False
mysql_config = /usr/bin/mysql_config
================================
yum -y install mysql mysql-devel mysql-connector-odbc   (mysql_config mysql (    mysql-client))
python setup.py build  
python setup.py install
(build   :error: command 'gcc' failed with exit status 1   :yum install gcc python-devel)
4.  simplejson
pip install simplejson

6. rabbitmq 컴 파일 설치:
1.Erlang    :
wget -P /usr/local/src https://packages.erlang-solutions.com/erlang/esl-erlang-src/otp_src_17.1.tar.gz
tar xf /usr/local/src/otp_src_17.1.tar.gz -C /usr/local/src
cd /usr/local/src/otp_src_17.1 && ./configure --prefix=/usr/local/erlang && make && make install
echo "#set erlang environment
export PATH=\$PATH:/usr/local/erlang/bin" >> /etc/profile && source /etc/profile
2.     :
#            python,                   ,     rabbitmq    python2.7.8  
yum -y install xmlto 
yum -y install python-simplejson python
3.rabbitmq    
wget -P /usr/local/src http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.1/rabbitmq-server-3.2.1.tar.gz
tar xf rabbitmq-server-3.2.1.tar.gz -C /usr/local/src
cd /usr/local/src/rabbitmq-server-3.2.1 && make TARGET_DIR=/usr/local/rabbitmq SBIN_DIR=/usr/local/rabbitmq/bin MAN_DIR=/usr/local/rabbitmq/man DOC_INSTALL_DIR=/usr/local/rabbitmq/doc install
echo "#set rabbitmq environment
export PATH=$PATH:/usr/local/rabbitmq/sbin" >> /etc/profile && source /etc/profile
4.    :
      
groupadd -r rabbitmq && useradd -s /sbin/nologin -g rabbitmq -r rabbitmq
      :
mkdir -p /usr/local/rabbitmq/var/log/
  :      /usr/local/rabbitmq/var/log/
  pid    /usr/local/rabbitmq/var/
    chmod +x /etc/init.d/rabbit && chkconfig add rabbit

     시작 스 크 립 트:
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides:          rabbitmq-server
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Description:       RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
# Source function library.
. /etc/init.d/functions
export HOME=/usr/local/rabbitmq
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/erlang/bin/
NAME=rabbitmq-server
DAEMON=/usr/local/rabbitmq/sbin/${NAME}
CONTROL=/usr/local/rabbitmq/sbin/rabbitmqctl
DESC=rabbitmq-server
USER=rabbitmq
ROTATE_SUFFIX=
INIT_LOG_DIR=/usr/local/rabbitmq/var/log/
PID_FILE=/usr/local/rabbitmq/var/rabbitmq.pid
START_PROG="daemon"
LOCK_FILE=/var/lock/subsys/$NAME
test -x $DAEMON || exit 0
test -x $CONTROL || exit 0
RETVAL=0
set -e
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
start_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        echo RabbitMQ is currently running
    else
        RETVAL=0
        set +e
        RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \
            > "${INIT_LOG_DIR}/startup_log" \
            2> "${INIT_LOG_DIR}/startup_err" \
            0<&- &
        $CONTROL wait $PID_FILE >/dev/null 2>&1
        RETVAL=$?
        set -e
        case "$RETVAL" in
            0)
                echo SUCCESS
                if [ -n "$LOCK_FILE" ] ; then
                    touch $LOCK_FILE
                fi
                ;;
            *)
                echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
                RETVAL=1
                ;;
        esac
    fi
}
stop_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        set +e
        $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
        RETVAL=$?
        set -e
        if [ $RETVAL = 0 ] ; then
            if [ -n "$LOCK_FILE" ] ; then
                rm -f $LOCK_FILE
            fi
        else
            echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
        fi
    else
        echo RabbitMQ is not running
        RETVAL=0
    fi
}
status_rabbitmq() {
    set +e
    if [ "$1" != "quiet" ] ; then
        $CONTROL status 2>&1
    else
        $CONTROL status > /dev/null 2>&1
    fi
    if [ $? != 0 ] ; then
        RETVAL=3
    fi
    set -e
}
rotate_logs_rabbitmq() {
    set +e
    $CONTROL rotate_logs ${ROTATE_SUFFIX}
    if [ $? != 0 ] ; then
        RETVAL=1
    fi
    set -e
}
restart_running_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        restart_rabbitmq
    else
        echo RabbitMQ is not runnning
        RETVAL=0
    fi
}
restart_rabbitmq() {
    stop_rabbitmq
    start_rabbitmq
}
case "$1" in
    start)
        echo -n "Starting $DESC: "
        start_rabbitmq
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        stop_rabbitmq
        echo "$NAME."
        ;;
    status)
        status_rabbitmq
        ;;
    rotate-logs)
        echo -n "Rotating log files for $DESC: "
        rotate_logs_rabbitmq
        ;;
    force-reload|reload|restart)
        echo -n "Restarting $DESC: "
        restart_rabbitmq
        echo "$NAME."
        ;;
    try-restart)
        echo -n "Restarting $DESC: "
        restart_running_rabbitmq
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
        RETVAL=1
        ;;
esac
exit $RETVAL

 
본 고 는 '돌고래 오 버 워 치' 블 로그 에서 나 온 것 으로 작가 에 게 연락 하 세 요!

좋은 웹페이지 즐겨찾기