第1章 环境规划
1.1 环境要求
[root@web01 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@web01 ~]# uname -m
x86_64
[root@web01 ~]# uname -r
2.6.32-573.el6.x86_64
[root@web01 ~]# uname -n
web01
[root@web01 ~]# uname -a
Linux web01 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@web01 ~]#
1.2 软件版本
软件 版本
nginx-1.10.1.tar.gz 1.10.1
php-5.5.32.tar.gz 5.5.32
mysql-5.5.49-linux2.6-x86_64.tar.gz 5.5.49
1.3 系统规划
1.3.1 IP规划
IP地址 软件
10.0.0.8 安装zabbix
第2章 安装Nginx
2.1 上传软件包
2.1.1 创建软件包存放目录
[root@web01 ~]# mkdir /home/oldboy/tools
[root@web01 ~]# ls -l /home/oldboy/
total 4
drwxr-xr-x 2 root root 4096 Jul 24 23:30 tools
[root@web01 ~]#
2.1.2 上传软件包
[root@web01 ~]# cd /home/oldboy/tools/
[root@web01 tools]# rz -E
rz waiting to receive.
[root@web01 tools]# ls
nginx-1.10.1.tar.gz
[root@web01 tools]#
2.2 安装Nginx依赖包
[root@web01 tools]# yum -y install openssl openssl-devel pcre pcre-devel
2.3 解压编译安装Nginx
2.3.1 创建nginx服务管理用户
[root@web01 tools]# useradd -s /sbin/nologin -M nginx
[root@web01 tools]# id nginx
uid=501(nginx) gid=501(nginx) groups=501(nginx)
[root@web01 tools]#
2.3.2 解压编译安装nginx
[root@web01 tools]# ls
nginx-1.10.1.tar.gz
[root@web01 tools]# tar xf nginx-1.10.1.tar.gz
[root@web01 tools]# cd nginx-1.10.1
[root@web01 nginx-1.10.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@web01 nginx-1.10.1]# ./configure --prefix=/application/nginx-1.10.1 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
编译正确结果:
nginx path prefix: "/application/nginx-1.10.1"
nginx binary file: "/application/nginx-1.10.1/sbin/nginx"
nginx modules path: "/application/nginx-1.10.1/modules"
nginx configuration prefix: "/application/nginx-1.10.1/conf"
nginx configuration file: "/application/nginx-1.10.1/conf/nginx.conf"
nginx pid file: "/application/nginx-1.10.1/logs/nginx.pid"
nginx error log file: "/application/nginx-1.10.1/logs/error.log"
nginx http access log file: "/application/nginx-1.10.1/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@web01 nginx-1.10.1]# make
编译正确结果:
sed -e "s|%%PREFIX%%|/application/nginx-1.10.1|" \
-e "s|%%PID_PATH%%|/application/nginx-1.10.1/logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/application/nginx-1.10.1/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/application/nginx-1.10.1/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/home/oldboy/tools/nginx-1.10.1'
[root@web01 nginx-1.10.1]# make install
make未报错结果:
|| mkdir -p '/application/nginx-1.10.1/logs'
test -d '/application/nginx-1.10.1/html' \
|| cp -R html '/application/nginx-1.10.1'
test -d '/application/nginx-1.10.1/logs' \
|| mkdir -p '/application/nginx-1.10.1/logs'
make[1]: Leaving directory `/home/oldboy/tools/nginx-1.10.1'
[root@web01 nginx-1.10.1]#
2.3.3 创建软链接文件
[root@web01 nginx-1.10.1]# ln -s /application/nginx-1.10.1/ /application/nginx
[root@web01 nginx-1.10.1]# ls -l /application/
total 4
lrwxrwxrwx 1 root root 26 Jul 24 23:45 nginx -> /application/nginx-1.10.1/
drwxr-xr-x 6 root root 4096 Jul 24 23:44 nginx-1.10.1
[root@web01 nginx-1.10.1]#
2.3.4 启动nginx,测试安装是否正常
[root@web01 /]# /application/nginx/sbin/nginx
[root@web01 /]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 3873 root 6u IPv4 15870 0t0 TCP *:http (LISTEN)
nginx 3874 nginx 6u IPv4 15870 0t0 TCP *:http (LISTEN)
[root@web01 /]# netstat -tunlp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3873/nginx
[root@web01 /]#
2.3.5 前段web页面测试
第3章 安装Mysql数据库
3.1 上传mysql二进制安装包
[root@web01 tools]# rz -E
rz waiting to receive.
[root@web01 tools]# ls
mysql-5.5.49-linux2.6-x86_64.tar.gz nginx-1.10.1 nginx-1.10.1.tar.gz
[root@web01 tools]#
3.2 创建mysql用户
[root@web01 tools]# useradd -s /sbin/nologin -M mysql
[root@web01 tools]# id mysql
uid=502(mysql) gid=502(mysql) groups=502(mysql)
[root@web01 tools]#
3.3 安装mysql
3.3.1 解压二进制文件并移动到application目录下
[root@web01 tools]# tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz
[root@web01 tools]# ls
mysql-5.5.49-linux2.6-x86_64 nginx-1.10.1
mysql-5.5.49-linux2.6-x86_64.tar.gz nginx-1.10.1.tar.gz
[root@web01 tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
3.3.2 创建软链接
[root@web01 tools]# ln -s /application/mysql-5.5.49/ /application/mysql
[root@web01 tools]# ls -l /application/
total 8
lrwxrwxrwx 1 root root 26 Jul 24 23:59 mysql -> /application/mysql-5.5.49/
drwxr-xr-x 13 root root 4096 Jul 24 23:58 mysql-5.5.49
lrwxrwxrwx 1 root root 26 Jul 24 23:45 nginx -> /application/nginx-1.10.1/
drwxr-xr-x 11 root root 4096 Jul 24 23:46 nginx-1.10.1
[root@web01 tools]#
3.3.3 创建mysql配置文件和启动文件
[root@web01 tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
[root@web01 tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@web01 tools]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10880 Jul 25 00:02 /etc/init.d/mysqld
[root@web01 tools]#
[root@web01 tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
3.3.4 初始化mysql数据库
[root@web01 tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
160725 0:08:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 3981 ...
OK
Filling help tables...
160725 0:08:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 3988 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h web01 password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
[root@web01 tools]#
3.4 递归修改/application/mysql目录
[root@web01 tools]# chown -R mysql.mysql /application/mysql/
[root@web01 tools]# ls -lr /application/mysql/
total 220
drwxr-xr-x 2 mysql mysql 4096 Jul 24 23:58 support-files
drwxr-xr-x 4 mysql mysql 4096 Jul 24 23:58 sql-bench
drwxr-xr-x 27 mysql mysql 4096 Jul 24 23:58 share
drwxr-xr-x 2 mysql mysql 4096 Jul 24 23:58 scripts
-rw-r--r-- 1 mysql mysql 2496 Mar 1 13:45 README
drwxr-xr-x 10 mysql mysql 4096 Jul 24 23:58 mysql-test
drwxr-xr-x 4 mysql mysql 4096 Jul 24 23:58 man
drwxr-xr-x 3 mysql mysql 4096 Jul 24 23:58 lib
-rw-r--r-- 1 mysql mysql 152629 Mar 1 13:53 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 Jul 24 23:58 include
drwxr-xr-x 2 mysql mysql 4096 Jul 24 23:58 docs
drwxr-xr-x 5 mysql mysql 4096 Jul 25 00:08 data
-rw-r--r-- 1 mysql mysql 17987 Mar 1 13:45 COPYING
drwxr-xr-x 2 mysql mysql 4096 Jul 25 00:03 bin
[root@web01 tools]#
3.5 修改环境变量
[root@web01 tools]# echo 'export PATH=/application/mysql/bin/:$PATH' >>/etc/profile
[root@web01 tools]# source /etc/profile
[root@web01 tools]# echo $PATH
/application/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@web01 tools]#
3.6 添加开机自启动
[root@web01 tools]# chkconfig --add mysqld
[root@web01 tools]# chkconfig --level 3 mysqld on
[root@web01 tools]# chkconfig --list|grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web01 tools]#
3.7 启动mysql数据库
[root@web01 tools]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[root@web01 tools]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 4274 mysql 10u IPv4 23779 0t0 TCP *:mysql (LISTEN)
[root@web01 tools]# netstat -tunlp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4274/mysqld
[root@web01 tools]#
3.8 优化mysql
[root@web01 tools]# mysqladmin -uroot password "oldboy123"
[root@web01 tools]# mysql -u root -poldboy123 -e "drop user 'root'@'::1';"
[root@web01 tools]# mysql -u root -poldboy123 -e "drop user ''@'localhost';"
[root@web01 tools]# mysql -u root -poldboy123 -e "drop user ''@web01;"
[root@web01 tools]# mysql -u root -poldboy123 -e "drop user root@web01;"
[root@web01 tools]# mysql -u root -poldboy123 -e "select user,host from mysql.user;"
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
[root@web01 tools]# mysql -u root -poldboy123 -e "flush privileges;"
[root@web01 tools]# mysql -u root -poldboy123 -e "drop database test;"
[root@web01 tools]# mysql -u root -poldboy123 -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
[root@web01 tools]#
第4章 安装php
4.1 上传php
[root@web01 /]# ls -l /home/oldboy/tools/
total 204636
-rw-r--r-- 1 root root 4984397 Aug 8 2011 libiconv-1.14.tar.gz
-rw-r--r-- 1 root root 185870973 Jul 3 10:52 mysql-5.5.49-linux2.6-x86_64.tar.gz
drwxr-xr-x 9 1001 1001 4096 Jul 24 23:42 nginx-1.10.1
-rw-r--r-- 1 root root 909077 Jun 12 11:43 nginx-1.10.1.tar.gz
-rw-r--r-- 1 root root 17773092 Jul 3 12:18 php-5.5.32.tar.gz
[root@web01 /]#
4.2 安装php依赖包
4.2.1 yum安装的依赖包
[root@web01 tools]# yum -y install zlib-devel libxml2 libxml2-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt
4.2.2 源码安装的依赖包
[root@web01 tools]# tar xf libiconv-1.14.tar.gz
[root@web01 tools]# cd libiconv-1.14
[root@web01 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@web01 libiconv-1.14]# make && make install
4.2.3 编译安装php
[root@web01 php-5.5.32]# ./configure \
--prefix=/application/php5.5.32 \
--with-mysql=/application/mysql/ \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--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-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-opcache=no \
--enable-ftp \
--with-gettext
正常编译结果:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@web01 php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@web01 php-5.5.32]# touch ext/phar/phar.phar
[root@web01 php-5.5.32]#make
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorygraphiterator.inc
directorytreeiterator.inc
clicommand.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
[root@web01 php-5.5.32]#make install
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /application/php5.5.32/etc/pear.conf
You may want to add: /application/php5.5.32/lib/php to your php.ini include_path
/home/oldboy/tools/php-5.5.32/build/shtool install -c ext/phar/phar.phar /application/php5.5.32/bin
ln -s -f phar.phar /application/php5.5.32/bin/phar
Installing PDO headers: /application/php5.5.32/include/php/ext/pdo/
[root@web01 php-5.5.32]#
4.3 创建软链接
[root@web01 php-5.5.32]# ln -s /application/php5.5.32/ /application/php
4.4 创建php-fpm配置文件和php启动文件
[root@web01 php-5.5.32]# pwd
/home/oldboy/tools/php-5.5.32
[root@web01 php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[root@web01 php-5.5.32]# ls -l /application/php/lib/
total 72
drwxr-xr-x 14 root root 4096 Jul 25 00:43 php
-rw-r--r-- 1 root root 69266 Jul 25 00:46 php.ini
[root@web01 php-5.5.32]# cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf
[root@web01 php-5.5.32]# ls -l /application/php/etc/
total 52
-rw-r--r-- 1 root root 1321 Jul 25 00:43 pear.conf
-rw-r--r-- 1 root root 22610 Jul 25 00:47 php-fpm.conf
-rw-r--r-- 1 root root 22610 Jul 25 00:43 php-fpm.conf.default
[root@web01 php-5.5.32]#
4.5 启动php
[root@web01 /]# /application/php/sbin/php-fpm
[root@web01 /]# netstat -tunlp|grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8348/php-fpm
[root@web01 /]#
[root@web01 /]# lsof -i :9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 8348 root 7u IPv4 131819 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 8349 nginx 0u IPv4 131819 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 8350 nginx 0u IPv4 131819 0t0 TCP localhost:cslistener (LISTEN)
[root@web01 /]#
第5章 测试Nginx+php+mysql
5.1 测试nginx+php链接
5.1.1 修改nginx配置文件
[root@web01 /]# cd /application/nginx/conf/
[root@web01 conf]# ls
fastcgi.conf koi-utf nginx.conf uwsgi_params
fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
fastcgi_params mime.types scgi_params win-utf
fastcgi_params.default mime.types.default scgi_params.default
[root@web01 conf]#
[root@web01 conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/access_zabbix.log main;
}
}
[root@web01 conf]#
5.1.2 重启nginx
[root@web01 conf]# ../sbin/nginx -t
nginx: the configuration file /application/nginx-1.10.1/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.10.1/conf/nginx.conf test is successful
[root@web01 conf]#
[root@web01 conf]# ../sbin/nginx -s reload
[root@web01 conf]#
5.1.3 编写phpinfo配置文件
[root@web01 html]# cat phpinfo.php
<?php
phpinfo();
?>
[root@web01 html]#
5.1.4 测试php解析
解析正常
5.1.5 测试mysqltest.php文件
[root@web01 html]# cat mysqltest.php
<?php
$link_id=mysql_connect('127.0.0.1','root','oldboy123') or mysql_error();
if($link_id){
echo "mysql successful by oldboy !";
}
else{
echo mysql_error();
}
?>
[root@web01 html]#
5.1.6 测试mysql链接
原因:没有启动数据库,启动数据库正常
第6章 安装zabbix
6.1 上传zabbix软件
[root@web01 tools]# ls
nginx-1.10.1 php-5.5.32 php-5.5.32.tar.gz zabbix-3.0.3.tar.gz
[root@web01 tools]# tar xf zabbix-3.0.3.tar.gz
[root@web01 tools]#
6.2 安装zabbix依赖包
[root@web01 tools]# yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel
6.3 编译安装zabbix
[root@web01 tools]# tar xf zabbix-3.0.3.tar.gz
[root@web01 /]# cd /home/oldboy/tools/zabbix-3.0.3
[root@web01 zabbix-3.0.3]# ls
aclocal.m4 ChangeLog config.sub database INSTALL Makefile.in NEWS
AUTHORS compile configure depcomp install-sh man README
bin conf configure.ac frontends m4 misc src
build config.guess COPYING include Makefile.am missing upgrades
[root@web01 zabbix-3.0.3]# ./configure --prefix=/application/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
编译报错:
checking size of void *... 8
checking for mysql_config... /application/mysql/bin//mysql_config
checking for main in -lmysqlclient... no
configure: error: Not found mysqlclient library
[root@web01 zabbix-3.0.3]#
解决方法:
[root@web01 zabbix-3.0.3]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysql_config
Enable proxy: no
Enable agent: no
Enable Java gateway: no
LDAP support: no
IPv6 support: no
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@web01 zabbix-3.0.3]#make install
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oldboy/tools/zabbix-3.0.3'
make[1]: Leaving directory `/home/oldboy/tools/zabbix-3.0.3'
[root@web01 zabbix-3.0.3]#
6.4 生成zabbix的web文件
[root@web01 zabbix-3.0.3]# mkdir /application/nginx/html/zabbix
[root@web01 zabbix-3.0.3]# cp -a /home/oldboy/tools/zabbix-3.0.3/frontends/php/* /application/nginx/html/zabbix
[root@web01 zabbix-3.0.3]#
6.5 导入zabbix数据库
6.5.1 创建zabbix数据库
[root@web01 zabbix-3.0.3]# mysql -uroot -poldboy123
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix_server default charset utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix_server.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@web01 zabbix-3.0.3]#
6.5.2 导入数据库
[root@web01 zabbix-3.0.3]# cd database/mysql/
[root@web01 mysql]# pwd
/home/oldboy/tools/zabbix-3.0.3/database/mysql
[root@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <schema.sql
[root@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <p_w_picpaths.sql
[root@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <data.sql
[root@web01 mysql]#
6.6 修改php.ini配置文件
[root@web01 lib]# sed -i 's#post_max_size = 8M#post_max_size = 16M#g' php.ini
[root@web01 lib]# sed -i 's#max_input_time = 60#max_input_time = 300#g' php.ini
[root@web01 lib]# sed -i 's#max_execution_time = 30#max_execution_time = 300#g' php.ini
[root@web01 lib]# sed -i '911 a date.timezone = Asia/Shanghai' php.ini
[root@web01 lib]# egrep "post_max_size = 16M|max_input_time = 300|max_execution_time = 300|date.timezone = Asia/Shanghai" php.ini
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
[root@web01 lib]#
6.7 重新启动php
[root@web01 lib]# pkill php-fpm
[root@web01 lib]# /application/php/sbin/php-fpm
[root@web01 lib]# lsof -i :9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 20234 root 7u IPv4 145689 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 20235 nginx 0u IPv4 145689 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 20236 nginx 0u IPv4 145689 0t0 TCP localhost:cslistener (LISTEN)
[root@web01 lib]#
6.8 修改zabbix配置文件
[root@web01 html]# cat ../conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/zabbix;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/access_zabbix.log main;
}
}
[root@web01 html]#
6.9 安装zabbix-agent客户端
[root@web01 html]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
[root@web01 html]# yum -y install zabbix-agent
6.10 修改zabbix-server配置文件
[root@web01 html]# vim /application/zabbix-server/etc/zabbix_server.conf
[root@web01 html]# grep '^[a-Z]' /application/zabbix-server/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix_server
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000
[root@web01 html]#
6.11 启动zabbix-server
[root@web01 html]# /application/zabbix-server/sbin/zabbix_server /application/zabbix-server/etc/zabbix_server.conf
报错:
zabbix_server [20894]: invalid parameter "/application/zabbix-server/etc/zabbix_server.conf"
原因:是没有加-c参数
[root@web01 html]# vim /application/zabbix-server/etc/zabbix_server.conf
[root@web01 html]#
[root@web01 html]# /application/zabbix-server/sbin/zabbix_server -c /application/zabbix-server/etc/zabbix_server.conf
[root@web01 html]# lsof -i :10051
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
zabbix_se 20916 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20921 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20922 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20923 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20924 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20925 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20926 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20927 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20928 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20929 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20930 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20931 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20932 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20933 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20937 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20938 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20943 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20944 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20945 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20946 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20947 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20948 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20953 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20954 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20955 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20957 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 20958 zabbix 4u IPv4 149190 0t0 TCP *:zabbix-trapper (LISTEN)
[root@web01 html]#
6.12 初始化zabbix
6.13 启动zabbix客户端
[root@web01 html]# /etc/init.d/zabbix-agent start
Starting Zabbix agent: [ OK ]
[root@web01 html]#