First, installation environment
Ubuntu 14.04LTS Postgresql-9.4.3 zabbix-2.4.5 httpd-2.4.12 php-5.6.10
Second, the choice reason
The reason for choosing the PostgreSQL database is that Zabbix's data business is relatively complex, more advantageous than MySQL, and MySQL's data sheets are prone to bad and often need to be repaired. Now, although Nginx is more popular, but for high stability, and do not need high concurrency of the application, recommend or use Apache, and use Prefork mode.
Three, installation preparation
Create ZBX system users to manage software related to Zabbix operations
$ useradd-m-r-d/zbx zbx$ aptinstall build-essential # Install the build environment
The next step is to add a language family to the system, so that Zabbix's multilingual options will take effect:
$ vim /var/lib/locales/supported.d/zabbix #Create a new file with the following content:
en_US.UTF-8 UTF-8
en_US.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
bg_BG.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
id_ID.UTF-8 UTF-8
it_IT.UTF-8 UTF-8
ja_JP.UTF-8 UTF-8
pt_BR.UTF-8 UTF-8
pt_PT.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8
sk_SK.UTF-8 UTF-8
uk_UA.UTF-8 UTF-8
$ locale-gen #Update the language of the system immediately
Iv. installation of PostgreSQL
Download and install
$ apt-get install libreadline-dev zlib1g-dev libssl-dev libxml2-dev libxslt-dev python-dev # 安装依赖
$ wget http://ftp.postgresql.org/pub/source/v9.4.3/postgresql-9.4.3.tar.bz2
$ tar –jxvf postgresql -C /usr/local/src
$ cd postgresql-9.4.3
$ ./configure
--prefix=/usr/local/postgresql
--with-segsize=8
--with-wal-segsize=64
--with-wal-blocksize=64
--with-python
--with-openssl
--with-libxml
--with-libxslt
--enable-thread-safety
$ make
$ make install
Setting environment variables
$ vim /etc/profile.d/pgsql.sh
export PGHOME=/usr/local/postgresql
export PGDATA=$PGHOME/data
export PATH=$PATH:$PGHOME/bin
export LD_LIBRARY_PATH=$PGHOME/lib/
alias pg_stop=‘su - fmc -c "pg_ctl -D $PGDATA stop"‘
alias pg_start=‘su - fmc -c "pg_ctl -D $PGDATA -l $PGHOME/pgsql.log start"‘
$ source /etc/profile.d/pgsql.sh
Initializing the database
$ su - zbx
No directory, logging in with HOME=/
$ initdb -D /usr/local/postgresql/data -E UTF8 --locale=C -U zbx -W
To share the dynamic link Library of PostgreSQL for the system, compiling Zabbix requires:
$ vim /etc/ld.so.conf.d/pgsql.conf
/ zabbix / postgresql / lib
$ ldconfig # Make it effective immediately
Start PostgreSQL and set up a database and user for Zabbix:
$ pg_start
$ psql -U zbx --dbname=postgres
create database zabbix;
create user zbx;
grant all on database zabbix to zbx;
\q
V. Installation of Apache
Installation dependencies
$ apt-get install libpcre3-dev
$ wgethttp://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.gz
$ tar -zxvf apr/apr-1.5.2.tar.gz
$ cd apr-1.5.2/
$ ./configure && make
$ make install
$ wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.gz
$ tar -zxvf apr-util-1.5.4.tar.gz
$ cd apr-util-1.5.4/
$ ./configure --with-apr=/usr/local/apr && make
$ make install
Compile and install Apache:
$ wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.12.tar.gz
$ tar -zxvf /httpd-2.4.12.tar.gz
$ cd httpd*
$ ./configure --prefix=/usr/local/httpd --enable-so --enable-mods-shared=most --with-mpm=prefork
$ make && make install
To configure vim/usr/local/httpd/conf/httpd.conf, add replacements or comments based on the default configuration to the following key fields:
#ServerAdmin [email protected]
ServerName 192.168.45.127:80
User zbx
Group zbx
Include conf/extra/httpd-mpm.conf
<IfModule mime_module>
AddHandler application/x-httpd-php .php
</IfModule>
DocumentRoot "/usr/share/html/zabbix"
<Directory "/usr/share/html/zabbix">
</Directory>
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
To configure/usr/local/httpd/conf/extra/httpd-mpm.conf, add replacements or comments based on the default configuration to the following key fields:
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 30
MaxConnectionsPerChild 100
</IfModule>
To start Apache:
$ cd /usr/local/httpd/
$ ./bin/apachectl start
Vi. Installation of PHP
Installation dependencies
$ apt-get install libbison-dev re2c libxml2-dev libjpeg-dev libpng-dev libfreetype6-dev
Install PHP and run it as an Apache module:
$ wget http://tw1.php.net/distributions/php-5.6.10.tar.bz2
$ tar -jxvf php-5.6.10.tar.bz2
$ cd php *
$ ./configure --prefix = / usr / local / php --with-config-file-path = / usr / local / php / etc --with-apxs2 = / usr / local / httpd / bin / apxs- with-pdo-pgsql = / usr / local / postgresql --with-pgsql = / usr / local / postgresql --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --enable-bcmath --enable-ctype --enable-sockets --enable-mbstring --with-gettext --disable-debug
$ make
$ make install
$ cp php.ini-production /fmc/php/etc/php.ini #Copy the standard configuration file
To configure the php.ini, replace the following key fields with the default configuration add:
$ vim /usr/local/php/etc/php.ini
...
post_max_size = 16M
max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai
...
Vii. installation of Zabbix
Installation dependencies
Install gettext libopenipmi-dev ipmitool libssh-dev fping libcurl4-openssl-dev libiksemel-dev Libsnmp-dev
Installing Zabbix
$ wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix_2.4.5.orig.tar.gz
$ tar -zxvf zabbix* && cd zabbix*
$ ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-postgresql=/usr/local/postgresql/bin/pg_config --with-net-snmp --with-jabber --with-libxml2 --with-libcurl --with-openipmi --enable-ipv6
$ make install
Initialize the Zabbix database:
$ cd database / postgresql # under the source directory
$ psql --username = fmc --dbname = zabbix --file = schema.sql #Note the order of data import
$ psql --username = fmc --dbname = zabbix --file = images.sql
$ psql --username = fmc --dbname = zabbix --file = data.sql
To configure Zabbix files:
$ vim /usr/local/zabbix/etc/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zbx
DBPassword=zbx
Start Zabbix-server, Zabbix-agentd:
$ cd / usr / local / zabbix
$. / sbin / zabbix_agentd start #Start the agent to monitor the server itself
$. / sbin / zabbix_server start #Start the service daemon
If you start the server times error: Error while loading shared Libraries:libpq.so.5:cannot open Shared object file:no such file or directory, Is the configuration Ld_library_path when setting the PostgreSQL environment variable.
To configure the front-end Web files for Zabbix:
$ cd zabbix-2.4.5 / frontends / # under the source directory
$ mkdir -p / usr / share / html / zabbix /
$ cp -ar php / * / usr / share / html / zabbix /
$ chown -R zbx: zbx / usr / share / html / zabbix /
Access Zabbix with a browser: http://192.168.45.127t, the front-end installation is graphical.
Once the installation is complete, you can use it. The default super User is (note case) Admin, password is Zabbix.
Eight, set boot boot
$ vim /etc/rc.local
su-zbx -c "pg_ctl -D $ PGDATA -l $ PGHOME / pgsql.log start"
cd / usr / local / zabbix && ./sbin/zabbix_agentd start
cd / usr / local / zabbix && ./sbin/zabbix_server start
cd / usr / local / httpd && ./bin/apachectl start
exit 0 #This sentence cannot be deleted in ubuntu, otherwise it will not take effect.
Ubuntu based apache+postgresql compilation installation Zabbix