# 3 Installation from sources

You can get the very latest version of Zabbix by compiling it from the
sources.

A step-by-step tutorial for installing Zabbix from the sources is
provided here.

#### Installing Zabbix daemons

##### 1 Download the source archive

Go to the [Zabbix download page](http://www.zabbix.com/download_sources)
and download the source archive. Once downloaded, extract the sources,
by running:

    $ tar -zxvf zabbix-3.4.0.tar.gz

::: notetip
Enter the correct Zabbix version in the command. It must
match the name of the downloaded archive.
:::

##### 2 Create user account

For all of the Zabbix daemon processes, an unprivileged user is
required. If a Zabbix daemon is started from an unprivileged user
account, it will run as that user.

However, if a daemon is started from a 'root' account, it will switch to
a 'zabbix' user account, which must be present. To create such a user
account (in its own group, "zabbix"),

on a RedHat-based system, run:

    groupadd --system zabbix
    useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

on a Debian-based system, run:

    addgroup --system --quiet zabbix
    adduser --quiet --system --disabled-login --ingroup zabbix --home /var/lib/zabbix --no-create-home zabbix

::: noteimportant
Zabbix processes do not need a home directory,
which is why we do not recommend creating it. However, if you are using
some functionality that requires it (e. g. store mysql credentials in
`$HOME/.my.cnf`) you are free to create it using the following
commands.


On RedHat-based systems, run:

    mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
    chown zabbix:zabbix /usr/lib/zabbix

On Debian-based systems, run:

    mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
    chown zabbix:zabbix /var/lib/zabbix


:::

A separate user account is not required for Zabbix frontend
installation.

If Zabbix [server](/manual/concepts/server) and
[agent](/manual/concepts/agent) are run on the same machine it is
recommended to use a different user for running the server than for
running the agent. Otherwise, if both are run as the same user, the
agent can access the server configuration file and any Admin level user
in Zabbix can quite easily retrieve, for example, the database password.

::: noteimportant
Running Zabbix as `root`, `bin`, or any other
account with special rights is a security risk.
:::

##### 3 Create Zabbix database

For Zabbix [server](/manual/concepts/server) and
[proxy](/manual/concepts/proxy) daemons, as well as Zabbix frontend, a
database is required. It is not needed to run Zabbix
[agent](/manual/concepts/agent).

SQL [scripts are provided](/manual/appendix/install/db_scripts) for
creating database schema and inserting the dataset. Zabbix proxy
database needs only the schema while Zabbix server database requires
also the dataset on top of the schema.

Having created a Zabbix database, proceed to the following steps of
compiling Zabbix.

##### 4 Configure the sources

When configuring the sources for a Zabbix server or proxy, you must
specify the database type to be used. Only one database type can be
compiled with a server or proxy process at a time.

To see all of the supported configuration options, inside the extracted
Zabbix source directory run:

    ./configure --help

To configure the sources for a Zabbix server and agent, you may run
something like:

    ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

::: noteclassic
--with-libcurl configuration option with cURL 7.20.0 or
higher is required for SMTP authentication, supported since Zabbix
3.0.0.<br>
--with-libcurl and --with-libxml2 configuration options are required for
virtual machine monitoring, supported since Zabbix 2.2.0.
:::

::: noteimportant
Since version 3.4 Zabbix will always compile with
the PCRE library; installing it is not optional. --with-libpcre=\[DIR\]
only allows pointing to a specific base install directory, instead of
searching through a number of common places for the libpcre
files.
:::

To configure the sources for a Zabbix server (with PostgreSQL etc.), you
may run:

    ./configure --enable-server --with-postgresql --with-net-snmp

To configure the sources for a Zabbix proxy (with SQLite etc.), you may
run:

    ./configure --prefix=/usr --enable-proxy --with-net-snmp --with-sqlite3 --with-ssh2

To configure the sources for a Zabbix agent, you may run:

    ./configure --enable-agent

You may use the --enable-static flag to statically link libraries. If
you plan to distribute compiled binaries among different servers, you
must use this flag to make these binaries work without required
libraries. Note that --enable-static does not work in
[Solaris](https://docs.oracle.com/cd/E18659_01/html/821-1383/bkajp.html).

::: noteimportant
 Using --enable-static option is not recommended
when building server.

In order to build the server statically you must have a static version
of every external library needed. There is no strict check for that in
configure script. 
:::

::: noteclassic
Command-line utilities zabbix\_get and zabbix\_sender are
compiled if --enable-agent option is used.
:::

::: noteclassic
 Add optional path to the MySQL configuration file
--with-mysql=/<path\_to\_the\_file>/mysql\_config to select the
desired MySQL client library when there is a need to use one that is not
located in the default location.

It is useful when there are several versions of MySQL installed or
MariaDB installed alongside MySQL on the same system. 
:::

::: noteclassic
Use --with-ibm-db2 flag to specify location of the CLI API.<br>
Use --with-oracle flag to specify location of the OCI API.
:::

For encryption support see [Compiling Zabbix with encryption
support](/manual/encryption#compiling_zabbix_with_encryption_support).

##### 5 Make and install everything

::: noteclassic
If installing from SVN, it is required to run first:

`$ make dbschema` 
:::

    make install

This step should be run as a user with sufficient permissions (commonly
'root', or by using `sudo`).

Running `make install` will by default install the daemon binaries
(zabbix\_server, zabbix\_agentd, zabbix\_proxy) in /usr/local/sbin and
the client binaries (zabbix\_get, zabbix\_sender) in /usr/local/bin.

::: noteclassic
To specify a different location than /usr/local, use a
--prefix key in the previous step of configuring sources, for example
--prefix=/home/zabbix. In this case daemon binaries will be installed
under <prefix>/sbin, while utilities under <prefix>/bin. Man
pages will be installed under <prefix>/share.
:::

##### 6 Review and edit configuration files

-   edit the Zabbix agent configuration file
    **/usr/local/etc/zabbix\_agentd.conf**

You need to configure this file for every host with zabbix\_agentd
installed.

You must specify the Zabbix server **IP address** in the file.
Connections from other hosts will be denied.

-   edit the Zabbix server configuration file
    **/usr/local/etc/zabbix\_server.conf**

You must specify the database name, user and password (if using any).

The rest of the parameters will suit you with their defaults if you have
a small installation (up to ten monitored hosts). You should change the
default parameters if you want to maximize the performance of Zabbix
server (or proxy) though. See the [performance
tuning](/manual/appendix/performance_tuning) section for more details.

-   if you have installed a Zabbix proxy, edit the proxy configuration
    file **/usr/local/etc/zabbix\_proxy.conf**

You must specify the server IP address and proxy hostname (must be known
to the server), as well as the database name, user and password (if
using any).

::: noteclassic
With SQLite the full path to database file must be
specified; DB user and password are not required.
:::

##### 7 Start up the daemons

Run zabbix\_server on the server side.

    shell> zabbix_server

::: noteclassic
Make sure that your system allows allocation of 36MB (or a
bit more) of shared memory, otherwise the server may not start and you
will see "Cannot allocate shared memory for <type of cache>." in
the server log file. This may happen on FreeBSD, Solaris 8.<br>
See the ["See also"](#see-also) section at the bottom of this page to
find out how to configure shared memory.
:::

Run zabbix\_agentd on all the monitored machines.

    shell> zabbix_agentd

::: noteclassic
Make sure that your system allows allocation of 2MB of
shared memory, otherwise the agent may not start and you will see
"Cannot allocate shared memory for collector." in the agent log file.
This may happen on Solaris 8.
:::

If you have installed Zabbix proxy, run zabbix\_proxy.

    shell> zabbix_proxy

#### Installing Zabbix web interface

##### Copying PHP files

Zabbix frontend is written in PHP, so to run it a PHP supported
webserver is needed. Installation is done by simply copying the PHP
files from frontends/php to the webserver HTML documents directory.

Common locations of HTML documents directories for Apache web servers
include:

-   /usr/local/apache2/htdocs (default directory when installing Apache
    from source)
-   /srv/www/htdocs (OpenSUSE, SLES)
-   /var/www/html (Debian, Ubuntu, Fedora, RHEL, CentOS)

It is suggested to use a subdirectory instead of the HTML root. To
create a subdirectory and copy Zabbix frontend files into it, execute
the following commands, replacing the actual directory:

    mkdir <htdocs>/zabbix
    cd frontends/php
    cp -a . <htdocs>/zabbix

If installing from SVN and planning to use any other language than
English, you must generate translation files. To do so, run:

    locale/make_mo.sh

`msgfmt` utility from gettext package is required.

::: noteclassic
Additionally, to use any other language than English, its
locale should be installed on the web server. See the ["See
also"](/manual/web_interface/user_profile#see_also) section in the "User
profile" page to find out how to install it if required.
:::

##### Installing frontend

##### Step 1

In your browser, open Zabbix URL:
http://<server\_ip\_or\_name>/zabbix

You should see the first screen of the frontend installation wizard.

![](../../../assets/en/manual/installation/install_1.png){width="550"}

##### Step 2

Make sure that all software prerequisites are met.

![](../../../assets/en/manual/installation/install_2.png){width="550"}

|Pre-requisite|Minimum value|Description|
|-------------|-------------|-----------|
|*PHP version*|5.4.0|<|
|*PHP memory\_limit option*|128MB|In php.ini:<br>memory\_limit = 128M|
|*PHP post\_max\_size option*|16MB|In php.ini:<br>post\_max\_size = 16M|
|*PHP upload\_max\_filesize option*|2MB|In php.ini:<br>upload\_max\_filesize = 2M|
|*PHP max\_execution\_time option*|300 seconds (values 0 and -1 are allowed)|In php.ini:<br>max\_execution\_time = 300|
|*PHP max\_input\_time option*|300 seconds (values 0 and -1 are allowed)|In php.ini:<br>max\_input\_time = 300|
|*PHP session.auto\_start option*|must be disabled|In php.ini:<br>session.auto\_start = 0|
|*Database support*|One of: MySQL, Oracle, PostgreSQL, IBM DB2|One of the following modules must be installed:<br>mysql, oci8, pgsql, ibm\_db2|
|*bcmath*|<|php-bcmath|
|*mbstring*|<|php-mbstring|
|*PHP mbstring.func\_overload option*|must be disabled|In php.ini:<br>mbstring.func\_overload = 0|
|*PHP always\_populate\_raw\_post\_data option*|must be disabled|Required only for PHP versions 5.6.0 or newer.<br>In php.ini:<br>always\_populate\_raw\_post\_data = -1|
|*sockets*|<|php-net-socket. Required for user script support.|
|*gd*|2.0 or higher|php-gd. PHP GD extension must support PNG images (*--with-png-dir*), JPEG (*--with-jpeg-dir*) images and FreeType 2 (*--with-freetype-dir*).|
|*libxml*|2.6.15|php-xml or php5-dom|
|*xmlwriter*|<|php-xmlwriter|
|*xmlreader*|<|php-xmlreader|
|*ctype*|<|php-ctype|
|*session*|<|php-session|
|*gettext*|<|php-gettext<br>Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available.|

Optional pre-requisites may also be present in the list. A failed
optional prerequisite is displayed in orange and has a *Warning* status.
With a failed optional pre-requisite, the setup may continue.

::: noteimportant
If there is a need to change the Apache user or
user group, permissions to the session folder must be verified.
Otherwise Zabbix setup may be unable to continue.
:::

##### Step 3

Enter details for connecting to the database. Zabbix database must
already be created.

![](../../../assets/en/manual/installation/install_3.png){width="550"}

##### Step 4

Enter Zabbix server details.

![](../../../assets/en/manual/installation/install_4.png){width="550"}

Entering a name for Zabbix server is optional, however, if submitted, it
will be displayed in the menu bar and page titles.

##### Step 5

Review a summary of settings.

![](../../../assets/en/manual/installation/install_5.png){width="550"}

##### Step 6

Download the configuration file and place it under conf/ in the
webserver HTML documents subdirectory where you copied Zabbix PHP files
to.

![](../../../assets/en/manual/installation/install_6.png){width="550"}

![](../../../assets/en/manual/installation/saving_zabbix_conf.png){width="350"}

::: notetip
Providing the webserver user has write access to conf/
directory the configuration file would be saved automatically and it
would be possible to proceed to the next step right away.
:::

##### Step 7

Finish the installation.

![](../../../assets/en/manual/installation/install_7.png){width="550"}

##### Step 8

Zabbix frontend is ready! The default user name is **Admin**, password
**zabbix**.

![](../../../assets/en/manual/quickstart/login.png){width="350"}

Proceed to [getting started with Zabbix](/manual/quickstart/login).

### See also

1.  [How to configure shared memory for Zabbix
    daemons](http://www.zabbix.org/wiki/How_to/configure_shared_memory)
