zabbix3.0.4安装部署

一、安装nginx:

1、安装相关的依赖包:

yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
2.创建用户:
groupadd nginx
useradd nginx nginx
3.下载nginx安装包:
wget http://nginx.org/download/nginx-1.9.15.tar.gz && tar xvf nginx-1.9.15.tar.gz && cd nginx-1.9.15
4.安装nginx:
tar xvf nginx-1.9.15.tar.gz && cd nginx-1.9.15
5.编译:
./configure --prefix=/usr/local/product/nginx1.9.15 --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre

make && make install
ln -s /usr/local/product/nginx1.9.15 /usr/local/nginx

二、安装MySQL:
1.添加mysql用户并创建目录:
groupadd mysql
mkdir -pv /data/mysql

useradd -r -g mysql -d /data/mysql -s /sbin/nologin mysql

chown -R mysql.mysql /data/mysql
2.安装cmake及相关依赖:
yum install cmake gcc* ncurses-devel -y 
3.下载mysql安装包:
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49.tar.gz
4.安装mysql
ar -xvf mysql-5.5.49.tar.gz && cd mysql-5.5.49

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/product/mysql5.5.49 -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci


make && make install

ln -s /usr/local/product/mysql5.5.49 /usr/local/mysql

chown -R mysql.mysql /usr/local/mysql
#进行编译安装,安装完成后就行软连接并给以权限
5.mysql的相关设置:
cd /usr/local/mysql/support-files/

cp my-medium.cnf /data/mysql/my.cnf

cp mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld
cd /usr/local/mysql/scripts

./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/
修改mysql配置文件my.cnf
datadir=/data/mysql/ #添加这一条
6.启动mysql:
/etc/init.d/mysqld start
7.登录mysql并创建所需的数据库:
mysql -uroot -p
mysql> create database zabbix character set utf8;#新建一个数据库叫zabbix
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
#给zabbix这个数据库授权,只允许zabbix这个用户通过本地登录,zabbix用户的密码为zabbix
flush privileges;
三.安装PHP:
1.下载php安装包:
wget http://cn2.php.net/get/php-5.5.35.tar.gz/from/this/mirror
2.解压并进行编译:
mv mirror php-5.5.35.tar.gz && tar xvf php-5.5.35.tar.gz && cd php-5.5.35

./configure --prefix=/usr/local/product/php-5.5.35 --with-config-file-path=/usr/local/product/php-5.5.35/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 && make install
ln -s /usr/local/product/php-5.5.35 /usr/local/php

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

cp php-fpm.conf.default php-fpm.conf
3.修改php.ini
max_execution_time=300
memory_limit=128M
post_max_size=16M
upload_max_filesize=2M
max_input_time=300
 
  
 
  
yum install mysql-devel -y
yum install net-snmp-devel -y
3. 解压并进行编译:
tar zxf zabbix-3.0.4.tar.gz && cd zabbix-3.0.4
./configure --prefix=/usr/local/zabbix-3.0.4/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install
4.创建zabbix使用用户:
groupadd zabbix
useradd zabbix zabbix
5.导入sql文件:
mysql -uroot -pzabbix zabbix < database/mysql/schema.sql 
mysql -uroot -pzabbix zabbix < database/mysql/images.sql
mysql -uroot -pzabbix zabbix < database/mysql/data.sql
#顺序不能错
.zabbix管理网站配置:
1.编辑nginx.conf配置文件
user  zabbix;
worker_processes  1;
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;
sendfile        on;
  keepalive_timeout  65;
include extra/*.conf;
    server {
        listen       80;
        server_name  localhost;
location / {
            root   /usr/share/nginx/zbx;
            index  index.php index.html index.htm;
        }
error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
location ~ \.php$ {
            root           /usr/share/nginx/zbx;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        } }
}
2.编辑zabbix_server.conf文件
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
3.配置web 站点
cd zabbix-3.0.4/
cp -r /zabbix-3.0.4/frontends/php /usr/local/nginx/html/zabbix
chown -R /usr/local/nginx/html/zabbix
六.启动服务:
1.启动nginx:
/usr/local/nginx/sbin/nginx
2.启动php:
/usr/local/php/sbin/php-fpm
3.启动zabbix _server:
/usr/local/zabbix-3.0.4/sbin/zabbix_server
七:添加开机自启动:
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local 
echo "/etc/init.d/mysqld start" >>/etc/rc.local
echo "/usr/local/zabbix-3.0.4/sbin/zabbix_server" >>/etc/rc.local
八:查看服务端口:
netstat -




 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  






 










你可能感兴趣的:(linux)