Compile and install Zabbix2.4.5 source code in Ubuntu 14.04
Installation environment:
Ubuntu14.04 LTS mysql 5.6 php-fpm nginx 1.8.0
Part 1: php + mysql + nginx component Installation
1. system updates
Sudo apt-get update & sudo apt-get upgrade
2. install php-fpm
Zabbix's web Front-end is written in php and needs php to run
Sudo apt-get install php-fpm (of course, php can also be compiled by source code)
3. Compile the source code mysql5.6
1. installation environment: Mysql-5.6.23.tar.gz
2. install necessary tools
Sudo apt-get install make bison g ++ build-essential libncurses5-dev cmake
3. Add a combined user to set the installation directory permission
Sudo groupadd mysql
Sudo useradd-g mysql-s/bin/false # create a user mysql and add it to the mysql group. mysql users are not allowed to log on to the system directly.
Sudo mkdir-p/usr/local/mysql # create the Mysql installation directory
Sudo mkdir-p/usr/local/mysql/data
Sudo mkdir-p/usr/local/mysql/log
Sudo chown-R mysql: mysql/usr/local/mysql/data
Sudo chown-R mysql: mysql/usr/local/mysql
4. Compile and install mysql
4.1 get source code package
Cd/usr/local/src
Sudo wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
4.2 decompress the mysql source code package
Sudo tar-zxvf mysql-5.6.23.tar.gz
5. Compile the configuration
Cd mysql-5.6.23
Sudo cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DSYSCONFDIR =/etc-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DEXTRA_CHARSETS = all-rows = 1-rows = 1-rows = 1-DWITH_READLINE = 1-rows = 1-rows =/usr/local /mysql/data-DMYSQL_USER = mysql-DWITH_DEBUG = 0
Note:
During re-compilation, you need to clear the old object file and cache information.
# Make clean
# Rm-f CMakeCache.txt
# Rm-rf/etc/my. cnf
Sudo make-j4 #-j: Run with multiple cores
Sudo make install
6. Related Configuration
6.1 configure startup
Sudo chmod + w/usr/local/mysql
Sudo cp./support-files/my-default.cnf/etc/my. cnf
Sudo cp./support-files/mysql. server/etc/init. d/mysqld
Sudo chmod 755/etc/init. d/mysqld
6.2 set environment variables for soft connections with Common commands
Sudo ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib/libmysqlclient. so.18
Sudo ln-s/usr/local/mysql/bin/mysql/usr/bin
Sudo ln-s/usr/local/mysql/bin/mysqladmin/usr/bin
6.3 initialize the database
Sudo/usr/local/mysql/scripts/mysql_install_db -- defaults-file =/etc/my. cnf -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql
7. Start mysql service for a try
Sudo/etc/init. d/mysqld start
8. Create a password for the root user after the startup is successful.
Mysqladmin-u root password
9. Use
Mysql-uroot-p
4. Install nginx
Sudo apt-get install nginx (of course, nginx can also be compiled by source code)
Nginx Configuration File Settings
In/etc/ngnix/site-available/default:
Copy code
# You may add here your
# Server {
#...
#}
# Statements for each of your virtual hosts to this file
##
# You shoshould look at the following URL's in order to grasp a solid understanding
# Of Nginx configuration files in order to fully unleash the power of Nginx.
# Http://wiki.nginx.org/Pitfalls
# Http://wiki.nginx.org/QuickStart
# Http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# File but keep this around for reference. Or just disable in sites-enabled.
#
# Please see/usr/share/doc/nginx-doc/examples/for more detailed examples.
##
Server {
Listen 80 default_server;
# Listen [:]: 80 default_server defaults 6only = on;
Root/usr/share/nginx/html/zabbix /;
Index. php index.html index.htm;
# Make site accessible from http: // localhost/
Server_name zabbix.example.com.cn;
Location /{
# First attempt to serve request as file, then
# As directory, then fall back to displaying a 404.
Try_files $ uri/= 404;
# Uncomment to enable naxsi on this location
# Include/etc/nginx/naxsi. rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui: process denied requests
# Location/RequestDenied {
# Proxy_pass http: // 127.0.0.1: 8080;
#}
# Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
# Error_page 500 502 503 504/50 x.html;
# Location =/50x.html {
# Root/usr/share/nginx/html;
#}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ \. Php $ {
Try_files $ uri = 404;
Fastcgi_split_path_info ^ (. + \. php) (/. +) $;
# NOTE: You shoshould have "cgi. fix_pathinfo = 0;" in php. ini
#
# With php5-cgi alone:
# Fastcgi_pass 127.0.0.1: 9000;
# With php5-fpm:
Fastcgi_pass unix:/var/run/php5-fpm.sock;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/share/nginx/html $ fastcgi_script_name;
Include fastcgi_params;
}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
}
# Another virtual host using mix of IP-, name-, and port-based configuration
#
# Server {
# Listen 8000;
# Listen somename: 8080;
# Server_name somename alias another. alias;
# Root html;
# Index index.html index.htm;
#
# Location /{
# Try_files $ uri/= 404;
#}
#}
# HTTPS server
#
# Server {
# Listen 443;
# Server_name localhost;
#
# Root html;
# Index index.html index.htm;
#
# Ssl on;
# Ssl_certificate cert. pem;
# Ssl_certificate_key cert. key;
#
# Ssl_session_timeout 5 m;
#
# Ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# Ssl_ciphers "HIGH :! ANULL :! MD5 or HIGH :! ANULL :! MD5 :! 3DES ";
# Ssl_prefer_server_ciphers on;
#
# Location /{
# Try_files $ uri/= 404;
#}
#}
Example @ ubuntu:/etc/nginx/sites-available $
Part 2: Zabbix compilation and installation and Web configuration
1. Dependency packages compiled and installed by zabbix
# Install the compilation Kit
Sudo apt-get install build-essential
# Install the package required by the php frontend
Sudo apt-get install libmysqlclient15-dev php5-gd php5-mysql
# Install the package required by zabbix, snmp \ curl \ ssl \ fping
Sudo apt-get install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping
2. Create zabbix users and zabbix groups
Sudo groupadd zabbix
Sudo useradd-r-s/usr/sbin/nologin-g zabbix
3. Download The zabbix source code package and decompress it.
Wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix_2.4.5.orig.tar.gz
Sudo tar-zxvf zabbix_2.4.5.orig.tar.gz-C/usr/local/src/
Cd/usr/local/src/zabbix-2.4.5/database
4. Database Initialization
Mysql-uroot-p-e "create database zabbix ;"
Mysql-uroot-p-e "grant all privileges on zabbix. * to zabbix @ localhost identified by 'zabbix ';"
Mysql-D zabbix-uzabbix-pzabbix <schema. SQL
Mysql-D zabbix-uzabbix-pzabbix <image. SQL
Mysql-D zabbix-uzabbix-pzabbix <data. SQL
5. zabbix compilation and Installation
Cd ..
./Configure -- prefix =/usr/local/zabbix -- enable-server -- enable-agent -- enable-proxy -- with-mysql -- with-net-snmp -- with-libcurl
Sudo make & sudo make install
# -- With-net-snmp is used to enable the SNMP protocol
# -- With-libcurl is used to monitor web sites
# -- Enable-server can only be used on the server
# For more information, see./configure -- help.
Ps: error configure: error: MySQL library not found missing libmysqlclient15-dev
6. Set the zabbix configuration file directory
Sudo mkdir/etc/zabbix
Cp conf/zabbix _ */etc/zabbix/
Sudo chown-R zabbix: zabbix/etc/zabbix/
7. modify the configuration file
Sudo vim/et/zabbix/zabbix_server.conf
Replace the two keywords DBUser DBPassword with the user and password set in mysqlDB.
8. Set zabbix to start upon startup
Sudo cp misc/init. d/debian/zabbix-server/etc/init. d
Sudo cp misc/init. d/debian/zabbix-agent/etc/init. d
Cd! $
Sudo chmod 755 zabbix -*
Sudo update-rc.d zabbix-server ults
Sudo update-rc.d zabbix-agent ults
9. zabbix web page installation settings
Sudo mkdir/usr/share/nginx/html/zabbix/
Cd/usr/src/zabbix-2.4.5/frontends/
Sudo cp-r php/*/usr/share/nginx/html/zabbix
Open http://zabbix.example.com.cn/zabbixin the browser to open the webinterface setup
1) zabbix checks php settings
The parameter to be modified by default is marked red. The php setting file is/etc/php5/cgi/php. ini.
Sudo restart php-fpm restart
2) zabbix checks mysql settings
Zabbix_server.conf must be consistent with the configuration path of mysql pid sock and other files in my. cnf.
My. cnf socket =/tmp/mysql. sock
Zabbix_server.conf DBSocket =/tmp/mysql. sock
Ps: if the error/var/run/mysqld. sock still persists
Maybe sudo ln-s/tmp/mysql. sock/var/run/mysqld. sock is a solution
3) Finally, you must manually copy the generated configuration file zabbix. conf. upload php files to/usr/share/nginx/html/zabbix/conf. The default zabbix user is admin and the password is zabbix. You must modify the password after logging on to the console.
�� A collection of Zabbix Tutorials:
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy Zabbix in CentOS 6.3
Zabbix distributed monitoring system practice
Under CentOS 6.3, Zabbix monitors apache server-status
Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3
Install Zabbix 2.0.6 in 64-bit CentOS 6.2
ZABBIX details: click here
ZABBIX: click here