Ubuntu14.04 under zabbix2.4.5 source code compilation installation

Source: Internet
Author: User
Tags fpm install php snmp

Installation Environment:

Ubuntu14.04 LTS mysql 5.6 php-fpm nginx 1.8.0

The first part, Php+mysql+nginx component installation

1. System Update

sudo apt-get update && sudo apt-get upgrade

2, Installation PHP-FPM

The web front end of Zabbix is written in PHP and requires PHP to run

sudo apt-get install php-fpm (of course, you can also compile PHP)

3, source code compilation mysql5.6

1. Installation Environment:
Mysql-5.6.23.tar.gz

2. Install the necessary tools


sudo apt-get install make Bison g++ build-essential libncurses5-Dev Cmake3. Add group user settings install directory permissions sudoGroupadd mysqlsudo useradd–g MySQL Mysql–s/bin/false#创建用户mysql并加入到mysql组, MySQL users are not allowed to log in directly to the system sudo mkdir–p/usr/local/MySQL #创建Mysql安装目录sudo mkdir-p/usr/local/mysql/Data sudo mkdir-p/usr/local/mysql/Logsudo Chown-r mysql:mysql/usr/local/mysql/Data sudo chown-r mysql:mysql/usr/local/Mysql4. Compiling and installing mysql4.1Get Source Package cd/usr/local/src sudo wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz4.2Extract MySQL source bundle sudo tar–zxvf Mysql-5.6.23.tar. gz5. Compiling the configuration CD Mysql-5.6.23sudo 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-dwith_myisam_storage_ engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-denabled_local_infile= 1-dmysql_datadir=/usr/local/mysql/data-dmysql_user=mysql-dwith_debug=0Note: When recompiling, you need to clear the old object file and cache information. # makeclean# RM- F cmakecache.txt# rm-rf/etc/ My.cnfsudo make-j4 #- J number means running sudo make install6 with multi-core . Related Configuration 6.1 Configure boot start sudo chmod +w/usr/local/ mysqlsudo cp./support-files/my-default.cnf/etc/ my.cnfsudo CP./ support-files/mysql.server/etc/init.d/ mysqldsudo chmod 755/etc/init.d/ mysqld6.2 Common command soft links, Setting environment variables sudo ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18sudo ln-s/usr/local/mysql/ bin/mysql/usr/ binsudo ln-s/usr/local/mysql/bin/mysqladmin/usr/ bin6.3 initializing database sudo/usr/local/ mysql/scripts/mysql_install_db--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql--datadir=/usr/local/mysql/ Data--user= mysql7 . Start the MySQL service try sudo/etc/init.d/ mysqld start8 . Create a password for the root user after successful startup Mysqladmin- u root password 9 . After successful use mysql-uroot-p

4. Installing Nginx

sudo apt-get install Nginx (of course, you can also compile the source of Nginx)

Nginx configuration File Settings

In/etc/ngnix/site-available/default:

# You could add here your# server {# ... #}# statements forEach of the your virtual hosts to thisfile# # should look at the following URL's in order to grasp a solid understanding# Nginx configuration Filesinchorder to fully unleash the power of nginx.# http://Wiki.nginx.org/pitfalls# http://Wiki.nginx.org/quickstart# http://wiki.nginx.org/configuration# # Generally, you'll want to move thisfilesomewhere, and start with a clean#fileBut keep this around forReference. Or just disableinchsites-enabled.## See/usr/share/doc/nginx-doc/examples/ for  Moredetailed examples.# #server {Listen thedefault_server;# Listen [::]: theDefault_server ipv6only=On ; Root/usr/share/nginx/html/zabbix/;    Index index.php index.html index.htm; # make site accessible from http://localhost/server_name zabbix.example.com.cn; Location/{# First attempt to serve request asfile, Then# as Directory, ThenFall back to displaying a404. Try_files $uri $uri/ =404; # Uncomment to enable Naxsi in this location # include/etc/nginx/Naxsi.rules} # only forNginx-naxsi used with nginx-naxsi-Ui:process denied requests #location/requestdenied {# Proxy_pass http://127.0.0.1:8080; #} #error_page404/404. html; # REDIRECT Server error pages to the static page/50x.html # #error_page - 502 503 504/50x.html; #location= /50x.html {# root/usr/share/nginx/html; #} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# Location~\.php$ {try_files $uri=404; Fastcgi_split_path_info^ (. +\.php) (/.+)$; # # note:you should have"cgi.fix_pathinfo = 0;" inchphp.ini # # # with PHP5-CGI alone: # Fastcgi_pass127.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,ifApache'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 {# listen8000; # Listen somename:8080; # server_name somename alias another.alias;# root html;# index index.html index.htm;## location/{# try_files $uri $uri/ =404; #}#}# HTTPS server# #server {# listen443; # server_name localhost;## root html;# index index.html index.htm;## SSL on;# ssl_certificate CERT.PEM ; # ssl_certificate_key cert.key;## ssl_session_timeout 5m;## ssl_protocols SSLv3 TLSv1 TLSv1.1TLSv1.2; # ssl_ciphers"high:!anull:! MD5 or high:!anull:! Md5:!3des"; # ssl_prefer_server_ciphers on;## Location/{# try_files $uri $uri/ =404; #}#}[email protected]:/etc/nginx/sites-available$

The second part, Zabbix compilation installation and Web front configuration

1. Zabbix compiled and installed dependency packages

#安装编译套件
sudo apt-get install build-essential
#安装php前端需要的包
sudo apt-get install Libmysqlclient15-dev php5-gd php5-mysql
#安装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 Zabbix

3, download Zabbix source package, and unzip

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 [email protected] 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 Compile and install

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 the SNMP protocol enabled
#--with-libcurl is used to monitor Web sites.
#--enable-server can only be used on the service side
#其它还有IPMI等, 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

DBUser Dbpassword These two keywords, replace with the user and password set in the previous MySQLdb

8, set Zabbix boot

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 defaults
sudo update-rc.d zabbix-agent defaults

9, Zabbix Web Interface 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 the Setup Http://zabbix.example.com.cn/zabbix Start Web interface in the browser

1) Zabbix will check the PHP settings

Red is the default need to modify the parameters, PHP settings file for/etc/php5/cgi/php.ini

sudo restart php-fpm restart

2) Zabbix will check the MySQL settings

Zabbix_server.conf and MY.CNF The configuration path of the PID sock and other files in MySQL are consistent

MY.CNF socket =/tmp/mysql.sock

zabbix_server.conf Dbsocket =/tmp/mysql.sock

PS: If still error/var/run/mysqld/mysqld.sock connection not on

Maybe sudo ln-s/tmp/mysql.sock/var/run/mysqld/mysqld.sock is a workaround

3) Finally, to manually upload the generated settings file zabbix.conf.php to/usr/share/nginx/html/zabbix/conf,zabbix the default user is admin, password is Zabbix, after landing must be modified.

Ubuntu14.04 under zabbix2.4.5 source code compilation installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.