You are not logged in.

#1 2013-03-01 15:47:30

senorsmile
Member
Registered: 2010-12-12
Posts: 72

howto: install zabbix server 2.0.5

Here is a script I made to install a new zabbix server on Arch.  I hope it helps someone. 

edited: Updated script as a couple of things didn't copy right and I added a few improvements.

#Date=20130405

#must be root!
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 
   exit 1
fi



#update all pacman and aur packages on system
pacman -Syyu
pacman -S base-devel fakeroot wget --needed --noconfirm

#install zabbix-server (which includes php front end as of this writing)
#replace packer with aur installer of choice if so desired
#packer -S zabbix-server php-apache --noedit --noconfirm
pacman -S php-apache postgresql php-pgsql php-gd fping net-snmp --noconfirm --needed

##### INSTALL iksemel
cd
wget https://aur.archlinux.org/packages/ik/iksemel/iksemel.tar.gz
tar xfv iksemel*
cd iksemel
makepkg --asroot
pacman -U iksemel*pkg.tar.xz --noconfirm

cd
wget https://aur.archlinux.org/packages/za/zabbix-server/zabbix-server.tar.gz
tar xfv zabbix-server*
cd zabbix-server
makepkg --asroot
pacman -U zabbix*pkg.tar.xz --noconfirm


cd



#set up apache
systemctl enable httpd
systemctl start httpd
echo "This is the default Zabbix server root. <br><br>  Please go to xx.xx.xx.xx/zabbix (where xx.xx.xx.xx is the ip address or hostname of the zabbix server)" | tee /srv/http/index.html

echo "
<Directory /srv/http/zabbix>
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>" >> /etc/httpd/conf/httpd.conf
chmod o+rx /srv/http/zabbix
chmod -R 755 /srv/http/zabbix/*


#set up php
#https://wiki.archlinux.org/index.php/LAMP
echo | tee -a /etc/httpd/conf/httpd.conf
echo "LoadModule php5_module modules/libphp5.so" | tee -a /etc/httpd/conf/httpd.conf
echo "Include conf/extra/php5_module.conf" | tee -a /etc/httpd/conf/httpd.conf

echo "application/x-httpd-php       php    php5" | tee -a /etc/httpd/conf/mime.types

echo "<?php phpinfo(); ?>" | tee /srv/http/test.php

systemctl restart httpd

sed -i -e 's/;extension=pgsql.so/extension=pgsql.so/g' /etc/php/php.ini
sed -i -e 's/;date.timezone = /date.timezone = America\/Los_Angeles/g' /etc/php/php.ini
sed -i -e 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php/php.ini
sed -i -e 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php/php.ini
sed -i -e 's/max_input_time = 60/max_input_time = 300/g' /etc/php/php.ini
sed -i -e 's/;extension=bcmath.so/extension=bcmath.so/g' /etc/php/php.ini
sed -i -e 's/;extension=sockets.so/extension=sockets.so/g' /etc/php/php.ini
sed -i -e 's/;extension=gd.so/extension=gd.so/g' /etc/php/php.ini

sed -i -e 's/;date.timezone =/date.timezone = America\/Los_Angeles/g' /etc/php/php.ini

#set up PostgreSQL
systemd-tmpfiles --create postgresql.conf
mkdir /var/lib/postgres/data
chown -c postgres:postgres /var/lib/postgres/data
sudo -i -u postgres initdb -D '/var/lib/postgres/data'
systemctl enable postgresql
systemctl start postgresql
echo "Create new postgres user."
echo "user name: zabbix"
echo "password: zabbix"
echo 
echo "Press [Enter] now to continue"
createuser -s -U postgres --interactive
#enter your user name
#zabbix


#zabbix post installation steps (populate postgresql db)

echo "local   zabbix      zabbix                            md5" | tee -a /var/lib/postgres/data/pg_hba.conf

systemctl restart postgresql

psql -a -U postgres -c "create database zabbix;"
cd /etc/zabbix/database/postgresql
psql -U zabbix zabbix < schema.sql
psql -U zabbix zabbix < images.sql
psql -U zabbix zabbix < data.sql

#echo "Now edit the zabbix server conf file to customize"
#echo "for your installation."
#echo 
#echo "Press any key to continue."
#read anykey
#vim /etc/zabbix/zabbix_server.conf

sed -i,backup -e "s/DBUser=root/DBUser=zabbix/g" /etc/zabbix/zabbix_server.conf
sed -i,backup -e "s/#DBPassword=/DBPassword=zabbix/g" /etc/zabbix/zabbix_server.conf



systemctl restart httpd
systemctl enable zabbix-server
systemctl start zabbix-server

echo "<?php
// Zabbix GUI configuration file
global \$DB;

\$DB['TYPE']     = 'POSTGRESQL';
\$DB['SERVER']   = 'localhost';
\$DB['PORT']     = '0';
\$DB['DATABASE'] = 'zabbix';
\$DB['USER']     = 'zabbix';
\$DB['PASSWORD'] = 'zabbix';

// SCHEMA is relevant only for IBM_DB2 database
\$DB['SCHEMA'] = '';

\$ZBX_SERVER      = 'localhost';
\$ZBX_SERVER_PORT = '10051';
\$ZBX_SERVER_NAME = '';

\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>" > /srv/http/zabbix/conf/zabbix.conf.php
chown zabbix:zabbix /srv/http/zabbix/conf/zabbix.conf.php
chmod 755 /srv/http/zabbix/conf/zabbix.conf.php

echo
echo "Zabbix 2.0 server is now installed. "
echo "Log in with user name Admin"
echo "and password zabbix"
echo

Last edited by senorsmile (2013-04-06 04:30:04)

Offline

Board footer

Powered by FluxBB