zabbix安装
环境:lnmp、centos6.7
1、安装数据库:
yum -y install ncurses-devel
cd /usr/src
tar zxvfcmake-2.8.6.tar.gz \\安装数据库需要cmake 先安装cmake
cd cmake-2.8.6
./configure
gmake && gmake install
安装完成后安装数据库
tar zxvf mysql-5.5.22.tar.gz
cd mysql-5.5.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
初始化数据库:
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
chown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/ --user=mysql \\初始化
启动数据库
service mysqld start
chmod 777 /etc/init.d/mysqld
service mysqld start
mysqladmin -u root password 'pwd123'
mysql -u root -p
2、yum 安装php
yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
libmcrypt-devel php-fpm
/etc/init.d/php-fpm start
3、安装nginx
安装支持的软件:yum -y install pcre-devel zlib-devel
创建用户和组:useradd -M -s /sbin/nologin nginx
编译安装:nginx
cd /usr/src
tar zxvf nginx-1.6.0.tar.gz
cd nginx-1.6.0
./configure --prefix=/usr/local/nginx--user=nginx --group=nginx --with-http_stub_status_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
ls -l /usr/local/sbin/nginx
nginx-t \\对配置文件进行检测
nginx \\启动nginx
netstat -anpt | grep nginx
vim /etc/init.d/nginx
添加
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Server Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
$PROG_FPM
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
status)
[-f $PID ] &> /dev/null
if [ $? -eq 0 ]
then
netstat -anpt| grep nginx
else
echo "Nginx isnot running."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
esac
exit 0
nginx -t \\语法检查
chmod +x /etc/init.d/nginx
chkconfig --add nginx
cd /usr/local/nginx/logs
ls //查看有没有pid进程文件
修改nginx配置文件配置nginx支持PHP环境
vim /usr/local/nginx/conf/nginx.conf
修改这样
43 location / {
44 root /var/www/html;
45 index index.html index.htm index.php;
46 }
找到
69 #location ~ \.php$ {
70 # root html;
71 # fastcgi_pass 127.0.0.1:9000;
72 # fastcgi_index index.php;
73 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
74 # include fastcgi_params;
75 #}
将其修改为
69 location ~ \.php$ {
70 root /var/www/html;
71 fastcgi_pass 127.0.0.1:9000;
72 fastcgi_index index.php;
73 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
74 include fastcgi.conf;
75 }
service nginx reload
cd /var/www/html 在这里新建一个index.php测试php内容为:
<?php
phpinfo();
?>
lnmp就安装到这接下来配置安装zabbix
4、安装zabbix server端
yum -y install libcurl-devel net-snmp-devel curl-devel perl-DBI
useradd zabbix -s /sbin/nologin
cd /usr/src/
tar zxvf zabbix-2.2.2.tar.gz
cd zabbix-2.2.2
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
make && make install
创建数据库,添加授权账号
Mysql> create database zabbix character set utf8;
Mysql> grant all on zabbix.* to zabbix@'localhost' identified by'zabbix';
Mysql> flush privileges;
Mysql> exit
导入zabbix数据至mysql
cd /usr/src/zabbix-2.2.2/database/mysql
mysql -uroot -p zabbix < schema.sql
mysql -uroot -p zabbix < images.sql
mysql -uroot -p zabbix < data.sql
拷贝zabbix启动文件在zabbix目录下面
cd misc/init.d/fedora/core/zabbix_server /etc/init.d
chmod 755 /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_server
修改ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server” //zabbix_server主程序启动位置
vim /usr/local/zabbix/etc/zabbix_server.conf //zabbix_server配置文件
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
zabbix 启动失败解决方法:
vim /etc/ld.so.conf 加入
/usr/local/mysql/lib
ldconfig
/etc/init.d/zabbix_server start
修改php的配置文件
vim /etc/php.ini
max_execution_time = 300
max_input_time = 300
date.timezone = PRC
post_max_size = 32M
复制web端到nginx的工作目录
cp -ra /usr/src/zabbix-2.2.2/frontends/php/ /var/www/html/zabbix
chown -R nginx.nginx /var/www/html/zabbix
重启LNMP服务
在浏览器输入http://IP/zabbix/index.php
点击下一步
数据库名称为:zabbix
数据库用户名:zabbix
数据库密码:zabbix