nginx

 

yum install pcre-devel zlib-devel -y 

 yum install openssl* -y 

 

groupadd -r nginx 

useradd -g nginx -r nginx 

 

tar -xf nginx-1.8.1.tar.gz 

cd nginx-1.8.1

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/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

 make && make install

 

提供服务启动脚本

 

#!/bin/sh

#

# 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:      /etc/nginx/nginx.conf

# config:      /etc/sysconfig/nginx

# pidfile:     /var/run/nginx.pid

 

# Source function library.

# Source networking configuration.

. /etc/sysconfig/network

 

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

 

nginx="/usr/sbin/nginx"

prog=$(basename $nginx)

 

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

 

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

 

lockfile=/var/lock/subsys/nginx.lock

make_dirs() {

   # make required directories   if [ -z "`grep $user /etc/passwd`" ]; then

       useradd -M -s /bin/nologin $user

   fi  

   options=`$nginx -V 2>&1 | grep 'configure arguments:'`

   for opt in $options; do

       if [ `echo $opt | grep '.*-temp-path'` ]; then

           value=`echo $opt | cut -d "=" -f 2`

           if [ ! -d "$value" ]; then

               # echo "creating" $value

               mkdir -p $value && chown -R $user $value

           fi  

       fi  

   done

}  

 

start() {

    [ -x $nginx ] || exit 5

    [ -f $NGINX_CONF_FILE ] || exit 6

    make_dirs

    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

    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

 

vim /etc/nginx/nginx.conf

 

user  nginx;

worker_processes  1;

 

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

 

 

events {

    worker_connections  1024;

}

 

 

http {

    include       mime.types;

    default_type  application/octet-stream;

 

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                     '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

 

   # access_log  logs/access.log  main;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 300m;

sendfile        on;

tcp_nopush     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;

keepalive_timeout  60;

tcp_nodelay on;

server_tokens off;

gzip  on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript text/css application/xml;

gzip_vary on;

 

 

    server {

        listen       80;

        server_name  www.qy.com;

 

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   html;

            index  index.html index.htm;

        }

 

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

 

       }

 

   }

 

include /etc/nginx/vhost/*.conf;

 

}

 

vim /etc/nginx/vhost/web.conf 

                                                           

server

        {

                listen       80;

                server_name 192.168.80.62;

                index index.php index.html index.htm default.html default.htm default.php;

                root  /usr/local/nginx/html;

location ~ .*\.(php|php5)?$

                        {

                                fastcgi_pass  127.0.0.1:9000;

                                fastcgi_index index.php;

                                include /etc/nginx/fastcgi_params;

                        }

                location /status {

                        stub_status on;

                        access_log   off;

                }

 

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

                        {

                                expires      30d;

                        }

                location ~ .*\.(js|css)?$

                        {

                                expires      12h;

                        }

 

                access_log off;

        }

                                                                                     

vim /etc/nginx/fastcgi_params 

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;

 

chmod +x /etc/rc.d/init.d/nginx 

                                   

chkconfig nginx --add

chkconfig nginx on

service nginx start 

 

php 

 

yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y

 

tar -xf php-5.5.34.tar.bz2 

cd php-5.5.34

 

./configure  --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl \

--enable-ftp --enable-sockets --disable-ipv6 --with-gd \

--with-jpeg-dir=/usr/local --with-png-dir=/usr/local \

--with-freetype-dir=/usr/local --enable-gd-native-ttf \

--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \

--with-gettext --with-libxml-dir=/usr/local --with-zlib \

--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \

--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

 

make && makeinstall

 

cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf

cp php.ini-production /usr/local/php/etc/php.ini

 

vim /usr/local/php/etc/php-fpm.conf

 

pid =/usr/local/php/var/run/php-fpm.pid

listen = 172.16.10.110:9000

pm.max_children = 25  #最大子进程数

pm.start_servers = 5  #开机预启动子进程数

pm.min_spare_servers = 2 #最小空闲子进程数

pm.max_spare_servers = 6 #最大空闲子进程

 

cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm

 

chmod +x /etc/rc.d/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

 

/etc/init.d/php-fpm start

 

 

打开php.ini配置文件,修改如下参数为如下值,否则zabbix安装不了。

 

 max_execution_time = 300

 memory_limit = 128M

 post_max_size = 16M

 upload_max_filesize = 2M

 max_input_time = 300 

date.timezone = Asia/Shanghai 

 

 

mysql 

 

yum install cmake bison ncurses ncurses-devel -y

 

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_DATADIR=/data/mysql/data \

-DMYSQL_USER=mysql \

-DMYSQL_TCP_PORT=3306

 

make makeinstall 

 

groupadd mysql

useradd mysql -g mysql  

 

mkdir -p /data/mysql

 

chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /data/mysql

 

 

 

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

 

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

 

 

vim /etc/my.cnf

 

[mysqld]

datadir=/data/mysql

socket= /var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[client]

socket=/var/lib/mysql/mysql.sock

 

 

cd /usr/local/mysql

 

scripts/mysql_install_db --user=mysql --datadir=/data/mysql

 

 

service mysqld start

 

设置开机自动启动服务

 

chkconfig mysqld on                   

 

 

zabbix 

 

yum install net-snmp-devel libxml2-devel libcurl-devel -y

yum install mysql-devel -y   

 

 cd zabbix-2.2.6

 

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2

maek makeinstall 


groupadd zabbix 

useradd -g zabbix zabbix 

                                                          

 

创建数据库 和导入 

 

create database zabbix default charset utf8;

grant all privileges on *.* to zabbix@127.0.0.1 identified by '123456';

mysql> select host,password from mysql.user;

+-----------+-------------------------------------------+

| host      | password                                  |

+-----------+-------------------------------------------+

| localhost | *AC241830FFDDC8943AB31CBD47D758E79F7953EA |

| han2      |                                           |

| 127.0.0.1 |                                           |

| ::1       |                                           |

| localhost |                                           |

| han2      |                                           |

| 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

+-----------+-------------------------------------------+

7 rows in set (0.00 sec)

 

cd /root/han/zabbix-2.2.6/database/mysql

mysql -root -p123.com zabbix < schema.sql

mysql -root -p123.com zabbix < images.sql             

mysql -root -p123.com zabbix < data.sql 

 

vim /usr/local/zabbix/etc/zabbix_server.conf

 

DBHost=127.0.0.1

DBName=zabbix

DBUser=zabbix

DBPassword=123.com

DBPort=3306

 

/usr/local/zabbix/sbin/zabbix_server 

 

cp /root/han/zabbix-2.2.6/frontends/php/* /usr/local/nginx/html/

 

登录 192.168.80.62 

 

 

wKioL1cpTQWi9p02AAETMIBjNoM161.png

 

 cd /usr/local/nginx/html                                     

 chmod -R 777 conf                     

 

wKioL1cpTRvCO0r-AAGLnhdVKko313.png

默认 用户 密码

admin  zabbix 

 

wKioL1cpTS3zZmkyAAHMlRX65sg331.png

         成功 !

 



 

zabbix 客户端安装


 

yum install net-snmp-devel libxml2-devel libcurl-devel -y

wget "http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz?r=http%3A%2F%2Fwww.zabbix.com%2Fdownload.php&ts=1395066528&use_mirror=jaist"

 

tar -xzvf zabbix-2.2.2.tar.gz

cd zabbix-2.2.2

 

./configure --prefix=/usr/local/zabbix/ --enable-agent

make

make install

 

# vim /usr/local/zabbix-2.2.2/etc/zabbix_agentd.conf

Server=192.168.80.62

ServerActive=192.168.80.62

Hostname=Zabbix server


groupadd zabbix 

useradd -g zabbix zabbix 

 

zabbix客户端启动


/usr/local/zabbix-2.2.2/sbin/zabbix_agentd