Sohaib's Tech Blog

Something for every one

How To Install Zabbix on Ubuntu 12.04 Precise & Configure — 2014

How To Install Zabbix on Ubuntu 12.04 Precise & Configure

Hello –

Today, I am going to show how you can install zabbix monitoring tool on Ubuntu 12.04 Precise.

Edit apt source list to add the PPA:

sudo nano /etc/apt/sources.list

Add the following items at the end of the file:

# Zabbix Application PPA

deb precise main
deb-src precise main

Save and close the file.

Next, we need to add the PPA’s key so that apt-get trusts the source:

sudo apt-key adv --keyserver --recv-keys C407E17D5F76A32B

We can now install Zabbix. It will pull in the necessary LAMP dependencies as well:

sudo apt-get update
sudo apt-get install zabbix-server-mysql apache2 mysql-server php5 php5-cli php5-common php5-mysql zabbix-frontend-php

During the installation, you will be asked to choose a password for the MySQL root account. Make a selection and confirm your choice.

Configuring the Zabbix Server
Next, we will need to configure the packages we just installed.

First, we will edit the main Zabbix server configuration file. Open the file with root privileges:

sudo nano /etc/zabbix/zabbix_server.conf

Search for the following properties and set them accordingly. Some may already be set correctly, and some you may have to add. Choose a password as well:

Save and close the file.

MySQL Configuration
Next, we will go into the package directory and unzip the SQL files that will define our database environment:

cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz

We will import the SQL files into our database. However, we first must create the database and do some initial configuration.

Log into MySQL as the root user using the password that you set up during installation:

mysql -u root -p
First, create a user for Zabbix that matches the information we entered in the “/etc/zabbix/zabbix_server.conf” file. Make sure to use the same information:

create user ‘zabbix’@’localhost’ identified by ‘Your.Password.Here’;
Next, we will create the Zabbix database:

create database zabbix;
Give control over the new database to the new user we created:

grant all privileges on zabbix.* to ‘zabbix’@’localhost’;
The following line will implement our new permissions:

flush privileges;
We are now done with the initial MySQL configuration. Exit back to the shell:

Now that we have our database set up, we can import the files that Zabbix needs to function. Enter the password for the user “zabbix” that you configured when prompted:

mysql -u zabbix -p zabbix < schema.sql
Do the same with the images file:

mysql -u zabbix -p zabbix < images.sql
And finally, import the data file:

mysql -u zabbix -p zabbix < data.sql

PHP Configuration
We need to adjust some values for the php processing of our monitoring data. Open the php configuration file:

sudo nano /etc/php5/apache2/php.ini
Search for and adjust the following entries. If they do not exist, add them:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC
Save and close the file.

Next, we will copy the Zabbix-specific php file into the configuration directory:

sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
Open the file:

sudo nano /etc/zabbix/zabbix.conf.php
Edit the following values. Use the same info as when you set up the database earlier:

$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Your.Password.Here'

Save and close the file.

Configuring Additional Files
There are a few more files that we need to configure.

First, we’ll move the Zabbix apache file from the package directory:

sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf
Ensure that the “alias” mod is enabled within Apache:

sudo a2enmod alias
Restart Apache to use the copied configuration file:

sudo service apache2 restart
Edit the Zabbix init file to ensure that it performs the correct action:

sudo nano /etc/default/zabbix-server
Go to the bottom and adjust the “START” property to read “yes”:

Save and close the file. We can now start Zabbix:

sudo service zabbix-server start
Installing and Configuring Zabbix Agent
Next, we need to configure the agent software that reports to the Zabbix server. We will install the agent software on our server machine and an additional client machine.

Follow these steps on both machines. Adjust the commands to reflect the correct information.

First, install the agent software:

sudo apt-get update
sudo apt-get install zabbix-agent
Next, we need to update the configuration files:

sudo nano /etc/zabbix/zabbix_agentd.conf
Edit the “Server” property to reflect the IP Address of the Zabbix server. For the agent configuration on the Zabbix server, you can use “”:

Adjust the “Hostname” property to reflect the hostname of the machine being monitored.

Save and close the file.

Restart the agent software:

sudo service zabbix-agent restart
Logging In for the First Time
In your web browser, navigate to your Zabbix server’s IP address followed by “/zabbix”:

You will be presented with a login screen. The default credentials are as follows:

Username = admin
Password = zabbix

How to Install Nginx with Google Page Speed — 2014

How to Install Nginx with Google Page Speed


Its been a long time since I last updated my blog as I was busy with so many other projects, Today I am going to show an easy way to install Nginx with Google Page speed.

I have only tested this with Ubuntu 12.04 Precise, So here it is

apt-get install python-software-properties
apt-get install software-properties-common
**OUTDATED** apt-add-repository ppa:sandyd/nginx-current-pagespeed
apt-add-repository ppa:adegtyarev/nginx-pagespeed
apt-get update
apt-get install nginx

You now have Nginx with Google Page Speed.

Test page speed by simply adding the following line

pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;

Below is my Nginx configuration

server {
#port to listen on
listen 80;

# server name

# root location
root /var/www/sohaib/public_html;

# access log
access_log /var/log/nginx/ main;

# PageSpeed
pagespeed on;

# let’s speed up PageSpeed by storing it in the super duper fast memcached
pagespeed MemcachedThreads 1;
pagespeed MemcachedServers “localhost:11211”;

# show half the users an optimized site, half the regular site
pagespeed RunExperiment on;
pagespeed AnalyticsID UA-XXXXXXXXXX-1;
pagespeed ExperimentVariable 1;
pagespeed ExperimentSpec “id=1;percent=50;level=CoreFilters;enabled=collapse_whitespace,remove_comments;”;
pagespeed ExperimentSpec “id=2;percent=50”;

# Filter settings
pagespeed RewriteLevel CoreFilters;
pagespeed EnableFilters collapse_whitespace,remove_comments;

# needs to exist and be writable by nginx
pagespeed FileCachePath /var/ngx_pagespeed_cache;

# This is a temporary workaround that ensures requests for pagespeed
# optimized resources go to the pagespeed handler.
location ~ “.pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+” { }
location ~ “^/ngx_pagespeed_static/” { }
location ~ “^/ngx_pagespeed_beacon$” { }


Few More Tips for Page Speed which might help optimize your site

# disable CoreFilters
pagespeed RewriteLevel PassThrough;

# enable collapse whitespace filter
pagespeed EnableFilters collapse_whitespace;

# enable JavaScript library offload
pagespeed EnableFilters canonicalize_javascript_libraries;

# combine multiple CSS files into one
pagespeed EnableFilters combine_css;

# combine multiple JavaScript files into one
pagespeed EnableFilters combine_javascript;

# remove tags with default attributes
pagespeed EnableFilters elide_attributes;

# improve resource cacheability
pagespeed EnableFilters extend_cache;

# flatten CSS files by replacing @import with the imported file
pagespeed EnableFilters flatten_css_imports;
pagespeed CssFlattenMaxBytes 5120;

# defer the loading of images which are not visible to the client
pagespeed EnableFilters lazyload_images;

# enable JavaScript minification
pagespeed EnableFilters rewrite_javascript;

# enable image optimization
pagespeed EnableFilters rewrite_images;

# pre-solve DNS lookup
pagespeed EnableFilters insert_dns_prefetch;

# rewrite CSS to load page-rendering CSS rules first.
pagespeed EnableFilters prioritize_critical_css;

# enable CoreFilters
pagespeed RewriteLevel CoreFilters;

# disable particular filter(s) in CoreFilters
pagespeed DisableFilters rewrite_images;

# enable additional filter(s) selectively
pagespeed EnableFilters collapse_whitespace;
pagespeed EnableFilters lazyload_images;
pagespeed EnableFilters insert_dns_prefetch;