安装zabbix 编译lnmp环境

1.0 系统环境

[root@BJ-idc-11-15 ~]# cat /etc/redhat-release      
CentOS release 6.5 (Final)


1.1 解决依赖

yum install gcc gcc-c++ pcre-devel openssl-devel libxml2-devel  GeoIP-devel bzip2-devel libmcrypt-devel \
libXpm-devel ncurses-devel libxslt-devel  net-snmp-devel libpng-devel mcrypt mhash-devel libevent-devel \
libcurl-devel  gd gd-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel autoconf  \


1.2 下载安装包      
wget
http://nginx.org/download/nginx-1.8.0.tar.gz

1.3 建立用户www

groupadd -g 108 -r www 
useradd -u 108 -r -g 108  www


1.4 编译安装

mkdir /data/application 
mkdir /data/logs/nginx �pv      tar xf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --user=www --group=www --prefix=/data/application/nginx  --with-http_ssl_module  --with-http_spdy_module  --with-http_realip_module  --with-http_addition_module  --with-http_xslt_module  --with-http_image_filter_module  --with-http_geoip_module  --with-http_sub_module  --with-http_dav_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_random_index_module  --with-http_secure_link_module  --with-http_degradation_module  --with-http_stub_status_module --http-client-body-temp-path=/data/application/nginx/tmp/client   --http-proxy-temp-path=/data/application/nginx/tmp/proxy/   --http-fastcgi-temp-path=/data/application/nginx/tmp/fcgi --http-uwsgi-temp-path=/data/application/nginx/tmp/uwsgi   --http-scgi-temp-path=/data/application/nginx/tmp/scgi   --with-pcre
make && make install


[root@BJ-idc-11-15 application]# tree /data/application/nginx/      
/data/application/nginx/      
├── conf      
│   ├── fastcgi.conf      
│   ├── fastcgi.conf.default      
│   ├── fastcgi_params      
│   ├── fastcgi_params.default      
│   ├── koi-utf      
│   ├── koi-win      
│   ├── mime.types      
│   ├── mime.types.default      
│   ├── nginx.conf      
│   ├── nginx.conf.default      
│   ├── scgi_params      
│   ├── scgi_params.default      
│   ├── uwsgi_params      
│   ├── uwsgi_params.default      
│   └── win-utf      
├── html      
│   ├── 50x.html      
│   └── index.html      
├── logs      
└── sbin      
    └── nginx

1.5 启动脚本

#!/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.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/data/application/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/data/application/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
   # make required directories
   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   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
        $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


[root@BJ-idc-11-15 application]# vim /etc/init.d/nginx 
[root@BJ-idc-11-15 application]# chmod +x /etc/init.d/nginx 
[root@BJ-idc-11-15 application]# /etc/init.d/nginx start 
chown: missing operand after `/data/application/nginx/tmp/client'      Try `chown --help' for more information.       chown: missing operand after `/data/application/nginx/tmp/proxy/'       Try `chown --help' for more information.       chown: missing operand after `/data/application/nginx/tmp/fcgi'       Try `chown --help' for more information.       chown: missing operand after `/data/application/nginx/tmp/uwsgi'       Try `chown --help' for more information.       chown: missing operand after `/data/application/nginx/tmp/scgi'       Try `chown --help' for more information.       Starting nginx:                                            [  OK  ]


解决报错

[root@BJ-idc-11-15 application]# chown  www.www nginx/* �R 
[root@BJ-idc-11-15 application]# /etc/init.d/nginx restart   
nginx: the configuration file /data/application/nginx/conf/nginx.conf syntax is ok       
nginx: configuration file /data/application/nginx/conf/nginx.conf test is successful       
Stopping nginx:                                            [  OK  ]    Starting nginx:                                            [  OK  ]


nginx主机配置文件优化

[root@BJ-idc-11-15 nginx]# cat conf/nginx.conf    
user  www www;      
worker_processes 8;      
#pid  /var/run/nginx/nginx.pid;      
# [ debug | info | notice | warn | error | crit ]      
#error_log  /data/logs/nginx_error.log;      
error_log  /dev/null;      
#Specifies the value for maximum file descriptors that can be opened by this process.      
worker_rlimit_nofile 51200;      
events      
{      
       use epoll;      
       #maxclient = worker_processes * worker_connections / cpu_number      
       worker_connections 51200;      
}      
http      
{      
       include       /data/application/nginx/conf/mime.types;      
       default_type  application/octet-stream;      
       #charset  gb2312,utf-8;      
       charset utf-8;

       log_format  main  '$remote_addr - $remote_user [$time_local] $request '    
                         '"$status" $body_bytes_sent "$http_referer" '      
                         '"$http_user_agent" "$http_x_forwarded_for"';      
       log_format fenxi '$remote_addr|$http_x_forwarded_for|[$time_local]|$http_host|$request|'      
                        '$status|$body_bytes_sent|$request_time|$upstream_response_time|$upstream_cache_status|$http_referer|'      
                        '$http_user_agent';

  # access_log  /log/access.log  main;    
       access_log  /dev/null;      
 
  #error_page 502 =200 /.busy.jpg;      
  #General Options      
       server_names_hash_bucket_size 128;      
       client_header_buffer_size    32k;      
       large_client_header_buffers  4 32k;      
       client_body_buffer_size    8m;  #256k      
     
       server_tokens off;      
       ignore_invalid_headers    on;      
       recursive_error_pages      on;      
       server_name_in_redirect off;      
     
       sendfile                    on;      
#timeouts      
       keepalive_timeout 60;      
       #test      
       #client_body_timeout    3m;      
       #client_header_timeout  3m;      
       #send_timeout            3m;

#TCP Options      
       tcp_nopush  on;      
       tcp_nodelay on;

#Fastcgi options      
       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;      
 
#hiden php version      
       fastcgi_hide_header X-Powered-By;      
#size limits      
       client_max_body_size       50m;      
  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;      
      
       proxy_temp_path            /dev/shm/proxy_temp;      
       fastcgi_temp_path          /dev/shm/fastcgi_temp;      
       client_body_temp_path      /dev/shm/client_body_temp;

       #upstream php    
        upstream php {      
                server 127.0.0.1:9000 max_fails=0;      
                server 127.0.0.1:9001 max_fails=0;      
       }      
       #upstream      
       fastcgi_next_upstream error timeout invalid_header http_500;      
       #limit_zone   limit  $binary_remote_addr  1m;


       include          vhosts/*.conf;    #目录存放虚拟站点.管理起来比较方便    
}    

nginx虚拟主机站点管理

[root@BJ-idc-11-15 conf]# pwd            #打印当前目录 别走丢了    
/data/application/nginx/conf      
[root@BJ-idc-11-15 conf]# mkdir vhosts   #建立虚拟主机管理目录      
[root@BJ-idc-11-15 conf]# cd vhosts/     
[root@BJ-idc-11-15 vhosts]# pwd          # 打印当前目录 别走丢了      
/data/application/nginx/conf/vhosts

[root@BJ-idc-11-15 vhosts]# vim www.test.conf   #建立一个虚拟主机站点

server 
        {  
            listen      80;      
            server_name  www.test.com;                #需要本地解析一下      
            index index.php index.html index.htm;      
            root   /data/code;                        #代码目录,也就是webapp站点      
                                              #日志也是统一管理,我们放在指定的目录下      
            access_log /data/logs/nginx/ccess_test.com.log  combined;      
            error_log  /data/logs/nginx/error_test.com.log;

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

            location ~ .*\.(js|css)?$ {    
                expires 24h;      
            }

            location /webstatus {    
                stub_status on;      
                access_log off;      
            }      
            location ~* \.php$ {      
            fastcgi_pass   127.0.0.1:9000;      
            fastcgi_index  index.php;      
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;      
            include        fastcgi_params;      
   }      
}

[root@BJ-idc-11-15 vhosts]# mkdir /data/code      
[root@BJ-idc-11-15 vhosts]# cd /data/code      
[root@BJ-idc-11-15 code]# echo "budongshu" >> /data/code/index.html 
[root@BJ-idc-11-15 code]# /etc/init.d/nginx reload     
nginx: the configuration file /data/application/nginx/conf/nginx.conf syntax is ok      
nginx: configuration file /data/application/nginx/conf/nginx.conf test is successful     
Reloading nginx:                                           [  OK  ]


window主机查看 本地hosts需要解析一下10.10.11.15   www.test.com

 

 

2.1 安装php

2.1.1 加压编译

[root@BJ-idc-11-15 ]# tar xf php-5.6.11.tar.gz
[root@BJ-idc-11-15 php-5.6.11]# cd php-5.6.11
[root@BJ-idc-11-15 php-5.6.11]#./configure --prefix=/data/application/php  --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-iconv-dir  --with-zlib --with-libxml-dir --enable-xml  --enable-pdo  --with-snmp  --with-xsl --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-sockets --enable-fpm  --with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --disable-debug --disable-ipv6 --enable-opcache 
[root@BJ-idc-11-15 php-5.6.11]# make && make install


php主配置文件

[root@BJ-idc-11-15 php-5.6.11]# cp php.ini-production /etc/php.ini 
php-fpm启动文件
[root@BJ-idc-11-15 php-5.6.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@BJ-idc-11-15 php-5.6.11]# chmod +x /etc/init.d/php-fpm
[root@BJ-idc-11-15 php-5.6.11]# chkconfig php-fpm on


修改php-fpm配置文件

[root@BJ-idc-11-15 php-5.6.11]# mkdir /data/logs/php

[root@BJ-idc-11-15 php-5.6.11]# cd /data/application/php/etc/

[root@BJ-idc-11-15 etc]# cp php-fpm.conf.default  php-fpm.conf

[root@BJ-idc-11-15 etc]# vim php-fpm.conf

[global]    
pid = /data/application/php/var/run/php-fpm.pid      
error_log = /data/logs/php/php-fpm.log      
log_level = notice      
emergency_restart_threshold = 10      
emergency_restart_interval = 1m      
[global]      
pid = /data/application/php/var/run/php-fpm.pid      
error_log = /data/logs/php/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 = 32      
pm.start_servers = 20      
pm.min_spare_servers = 5      
pm.max_spare_servers = 35      
pm.max_requests = 120      
pm.status_path = /php_status

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:/data/application/php/bin      
env[TMP] = /tmp      
env[TMPDIR] = /tmp      
env[TEMP] = /tmp

启动php-fpm

[root@BJ-idc-11-15 php-5.6.11]# /etc/init.d/php-fpm start      
Starting php-fpm  done


3.1 安装MySQL

3.1.1 安装mysql客户端

[root@BJ-idc-11-15 ]# rpm �qa mysql 
[root@BJ-idc-11-15 ]# yum install mysql �y


3.1.2 建立用户

[root@BJ-idc-11-15 ]# 
groupadd mysql -g 27  
[root@BJ-idc-11-15 ]# 
useradd -u 27 -g mysql -c "MySQL Server" mysql  -s

/sbin/nologin      

3.1.3 安装cmake

[root@BJ-idc-11-15 ]# wget http://down1.chinaunix.net/distfiles/cmake-2.8.5.tar.gz
[root@BJ-idc-11-15 ]# tar xf cmake-2.8.5.tar.gz  
[root@BJ-idc-11-15 ]# cd cmake-2.8.5       
[root@BJ-idc-11-15 cmake-2.8.5]# ./configure && make -j 4 && make install  
[root@BJ-idc-11-15 cmake-2.8.5]# cp -a /usr/local/bin/cmake  /usr/bin/cmake


3.1.4 编译安装mysql

[root@BJ-idc-11-15 ~]# tar xf mysql-5.6.14.tar.gz 
[root@BJ-idc-11-15 ~]# cd mysql-5.6.14
[root@BJ-idc-11-15 mysql-5.6.14]# cmake . -DCMAKE_INSTALL_PREFIX=/data/application/mysql   -DMYSQL_DATADIR=/data/mysql/3306/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=yes  -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on 
[root@BJ-idc-11-15 mysql-5.6.14]# cp support-files/mysql.server.sh /etc/init.d/mysqld  
[root@BJ-idc-11-15 mysql-5.6.14]# chmod +x /etc/init.d/mysqld       
[root@BJ-idc-11-15 mysql-5.6.14]# chkconfig --add mysqld       
[root@BJ-idc-11-15 mysql-5.6.14]# chkconfig mysqld on 
[root@BJ-idc-11-15 mysql-5.6.14]# vim /etc/init.d/mysqld
basedir=/data/application/mysql
  
datadir=/data/mysql/3306/data


[root@BJ-idc-11-15 mysql-5.6.14]# chown mysql.mysql /data/application/mysql/ �R 
[root@BJ-idc-11-15 mysql-5.6.14]# mkdir /data/mysql/3306/data �pv  #建立数据目录
mkdir: created directory `/data/mysql'
mkdir: created directory `/data/mysql/3306
mkdir: created directory `/data/mysql/3306/data'
[root@BJ-idc-11-15 mysql-5.6.14]# chown mysql.mysql /data/mysql/ �R


初始化mysql

[root@BJ-idc-11-15 mysql-5.6.14]# cd /data/application/mysql
[root@BJ-idc-11-15 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/data/application/mysql/ --datadir=/data/mysql/3306/data/

 

出现如上信息代表 初始化成功

mysql 配置文件

[root@BJ-idc-11-15 data]# cat /etc/my.cnf    
[mysqld]      
port                                       = 3306      
basedir                                    = /data/application/mysql      
datadir                                    = /data/mysql/3306/data      
socket                                     = /tmp/mysql.sock      
pid-file                                   = /data/mysql/3306/mysql.pid

skip_external_locking    
explicit_defaults_for_timestamp

character-set-server                    = utf8    
default-storage-engine                  = InnoDB      
 
tmp_table_size                         = 64M      
max_heap_table_size                    = 64M

table_open_cache                         = 4096    
table_definition_cache                   = 4096      
thread_cache_size                        = 256      
thread_stack                             = 256K

sort_buffer_size                         = 1M    
join_buffer_size                         = 1M

skip-name-resolve    
back_log                                 = 1000      
max_connections                          = 2000      
max_connect_errors                       = 10000      
max_allowed_packet                       = 64M      
interactive_timeout                      = 7200      
wait_timeout                             = 7200      
slow_query_log                           = 1      
long_query_time                          = 0.5      
slow_query_log_file                      = /data/mysql/3306/logs/slow.log

key_buffer_size                           = 64M    
read_buffer_size                          = 1M      
read_rnd_buffer_size                      = 16M      
bulk_insert_buffer_size                   = 8M      
myisam_sort_buffer_size                   = 10G      
myisam_max_sort_file_size                 = 1G

transaction-isolation                     = REPEATABLE-READ    
innodb_fast_shutdown                      = 1      
innodb_force_recovery                     = 0      
innodb_file_per_table                     = 1      
innodb_open_files                         = 4096      
innodb_buffer_pool_size                   = 200M      
innodb_data_file_path                     = ibdata1:256M:autoextend:max:10G      
innodb_data_home_dir                      = /data/mysql/3306/data      
innodb_flush_method                       = O_DIRECT      
innodb_thread_concurrency                 = 16      
innodb_log_buffer_size                    = 16M      
innodb_log_file_size                      = 512M      
innodb_log_files_in_group                 = 3      
innodb_log_group_home_dir                 = /data/mysql/3306/data      
innodb_flush_log_at_trx_commit            = 2      
innodb_max_dirty_pages_pct                = 75      
innodb_lock_wait_timeout                  = 50      
innodb_support_xa                         = 0


innodb_adaptive_flushing    
innodb_change_buffering                   = inserts      
innodb_file_format                        = Antelope      
innodb_io_capacity                        = 1000      
innodb_old_blocks_pct                     = 37      
innodb_old_blocks_time                    = 0      
innodb_read_ahead_threshold               = 56      
innodb_read_io_threads                      = 4      
innodb_write_io_threads                     = 4      
innodb_replication_delay                    = 0      
innodb_spin_wait_delay                      = 6      
innodb_stats_sample_pages                   = 8      
innodb_use_sys_malloc


binlog-format                            = mixed

# ****** Master Options ******    
server-id                                = 1      
log-bin                                  = /data/mysql/3306/logs/binlog/mysql-bin      
log-bin-index                            = /data/mysql/3306/logs/binlog/mysql_bin.index      
binlog_cache_size                        = 4M      
max_binlog_size                          = 512M      
sync_binlog                              = 0

log-slave-updates

log_bin_trust_function_creators           = 1    
slave_compressed_protocol                 = 1      
slave-net-timeout                         = 10

[mysqld_safe]    
user                                      = mysql      
open-files-limit                          = 10240

[mysqldump]    
quick      
default-character-set                     = utf8      
max_allowed_packet                        = 1M

mysql启动报错解决

[root@BJ-idc-11-15 data]# /etc/init.d/mysqld start      
Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/3306/mysql.pid).


那么现在看报错日志

[root@BJ-idc-11-15 data]# cat BJ-idc-11-15.err     
160329 09:50:42 mysqld_safe Starting mysqld daemon with databases from /data/mysql/3306/data      /data/application/mysql/bin/mysqld: File '/data/mysql/3306/logs/binlog/mysql_bin.index' not found (Errcode: 2 - No such file or directory)      
2016-03-29 09:50:43 10609 [ERROR] Aborting
2016-03-29 09:50:43 10609 [Note] Binlog end     
2016-03-29 09:50:43 10609 [Note] /data/application/mysql/bin/mysqld: Shutdown complete


日志报错说么有这个目录,那么建立目录

[root@BJ-idc-11-15 data]#  mkdir /data/mysql/3306/logs/binlog �pv 
[root@BJ-idc-11-15 data]# /etc/init.d/mysqld start      Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/3306/mysql.pid).


再次看日日志 如图所示:

image

[root@BJ-idc-11-15 data]# pwd     
/data/mysql/3306/data
[root@BJ-idc-11-15 data]# rm -fr ibdata1  ib_logfile0 ib_logfile1


再次启动试试,成功

[root@BJ-idc-11-15 data]# /etc/init.d/mysqld restart     
Shutting down MySQL. SUCCESS!       
Starting MySQL.... SUCCESS!


查看目录文件

[root@BJ-idc-11-15 data]# ll -lh     
total 1.8G      
-rw-rw---- 1 mysql mysql   56 Mar 29 10:06 auto.cnf      
-rw-r----- 1 mysql mysql  22K Mar 29 10:11 BJ-idc-11-15.err      
-rw-rw---- 1 mysql mysql 256M Mar 29 10:11 ibdata1      
-rw-rw---- 1 mysql mysql 512M Mar 29 10:11 ib_logfile0      
-rw-rw---- 1 mysql mysql 512M Mar 29 10:06 ib_logfile1      
-rw-rw---- 1 mysql mysql 512M Mar 29 10:06 ib_logfile2      
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 mysql      
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 performance_schema      
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 test


测试php和mysql的连接

[root@BJ-idc-11-15 code]# cat index.php      
<?php      
  $link = mysql_connect('127.0.0.1','root','');  #我的密码为空.      
  if ($link)      
    echo "Success...";      
  else      
    echo "Failure...";      
  mysql_close();      
  phpinfo();      
?>


如图

安装zabbix 编译lnmp环境_第1张图片

 

4.1 安装zabbix server

安装脚本

#!/bin/bash

#本人数据库用户名root 密码:mysqlpass

#新建zabbix数据库

mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "create database zabbix character set utf8 collate utf8_bin;"

#设置zabbix用户名和密码

mysql -uroot  -p"mysqlpass"   -h 127.0.0.1   -e "grant all privileges on zabbix.* to [email protected] identified by 'zabbixpass'"

mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixpass'"  

mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "flush privileges”

mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "show databases;"

#安装zabbix

yum -y  install javacc libxml2-devel iksemel-devel unixODBC-devel OpenIPMI-devel curl-devel mysql-devel

#��安�  
wget
http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz/    
tar xf zabbix-2.2.6.tar.gz    
cd /root/zabbix-2.2.6    
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp \    
--with-libcurl --with-libxml2--with-openipmi --with-unixodbc --with-jabber    
make && make install

#�入���  
useradd zabbix    
cd  /root/zabbix-2.2.6/database/mysql    
mysql  -h127.0.0.1 -uzabbix -pzabbixpass zabbix < schema.sql     
mysql  -h127.0.0.1 -uzabbix -pzabbixpass zabbix < images.sql    
mysql  -h127.0.0.1 -uzabbix -pzabbixpass zabbix < data.sql

#php.ini  
sed -i "/date.timezone =/c date.timezone = 'Asia/Shanghai'" /etc/php.ini    
sed -i '/post_max_size = /c post_max_size = 30M' /etc/php.ini    
sed -i '/max_input_time = /c max_input_time = 300' /etc/php.ini    
sed -i '/max_execution_time =/c max_execution_time = 300' /etc/php.ini

#增加服务端口  
cat >>/etc/services <<EOF    
zabbix-agent   10050/tcp #Zabbix Agent    
zabbix-agent   10050/udp #Zabbix Agent    
zabbix-trapper 10051/tcp #Zabbix Trapper    
zabbix-trapper 10051/udp #Zabbix Trapper    
EOF

#配置zabbix_server  
sed -i "/DBHost=localhost/c DBHost=127.0.0.1" /usr/local/zabbix/etc/zabbix_server.conf    
sed -i "/DBName=zabbix/c DBName=zabbix" /usr/local/zabbix/etc/zabbix_server.conf    
sed -i "/DBUser=root/c DBUser=zabbix" /usr/local/zabbix/etc/zabbix_server.conf    
sed -i "/DBPassword=/c DBPassword=zabbixpass" /usr/local/zabbix/etc/zabbix_server.conf


#配置���本    
cd /root/zabbix-2.2.6/    
cp misc/init.d/fedora/core5/* /etc/init.d/    
chmod +x /etc/init.d/zabbix_*    
sed  -i  's@\(ZABBIX_BIN\)="/usr/local/sbin/zabbix_server"@\1="/usr/local/zabbix/sbin/zabbix_server"@g' /etc/init.d/zabbix_server    
sed  -i  's@\(ZABBIX_BIN\)="/usr/local/sbin/zabbix_agentd"@\1="/usr/local/zabbix/sbin/zabbix_agentd"@g' /etc/init.d/zabbix_agentd

/etc/init.d/zabbix_server start  
chkconfig  zabbix_server on    
#配置zabbix web站点    
cat >> /data/application/nginx/conf/vhosts/zabbix.conf <<EOF    
server{    
   listen       80;    
   server_name bds.zabbix.com;    
   index index.php;    
   root /data/code/zabbix;    
   #access_log /data/logs/nginx/zabbix_access.log fenxi:    
   error_log  /data/logs/nginx/zabbix_error.log ;    
   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {    
       expires 30d;    
   }    
   location ~* \.php$ {    
       fastcgi_pass   127.0.0.1:9000;    
       fastcgi_index  index.php;    
       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;    
       include        fastcgi_params;    
   }    
}    
EOF    
mkdir /data/code/zabbix    
cd /data/code/zabbix    
cp -a /root/zabbix-2.2.6/frontends/php/* .    
chown www.www /data/code/* -R

/etc/init.d/zabbix_server start  
/etc/init.d/php-fpm reload  
/etc/init.d/mysqld reload  
/etc/init.d/nginx reload  
 

window 本地解析 10.10.11.15  bds.zabbix.com

安装zabbix 编译lnmp环境_第2张图片

安装zabbix 编译lnmp环境_第3张图片

 

安装zabbix 编译lnmp环境_第4张图片

 

 
解决上图片中红色字体的错误
php动态编译模块
cd /root/php-5.6.11/ext/gettext
/data/application/php/bin/phpize
./configure --with-php-config=/data/application/php/bin/php-config
make && make install
/etc/init.d/php-fpm restart 

刷新一下zabbix前端


你可能感兴趣的:(下载安装)