Chapter 3. Installing Under Windows

Installations

  1. Download and install the following pieces of software:

Configure PHP

  1. If using PHP 4, move the files in c:\php\dlls to c:\php.

  2. Add the following to your Windows PATH environment variable c:\php. The Windows path can be accessed via the Control Panel at: System | Advanced | Environment Variables | System Variables..

  3. Add the following two new environment variables to your system using the procedure above: PHPRC=c:\php.

    1. If using PHP 4, create this variable:  MIBDIRS=c:\php\mibs
    2. If using PHP 5, create this variable:  MIBDIRS=c:\php\extras\mibs
  4. If using PHP 4.3.5 or less (not recommended), create the following directory c:\tmp.

  5. Rename the file c:\php\php.ini.dist to php.ini, and make the following changes to it:

    If using PHP 4 uncomment the following lines:

    extension_dir = c:\php\extensions
    extension=php_snmp.dll
    extension=php_sockets.dll
    cgi.force_redirect = 0

    If using PHP 5 uncomment the following lines:

    extension_dir = c:\php\ext
    extension=php_mysql.dll
    extension=php_snmp.dll
    extension=php_sockets.dll
    cgi.force_redirect = 0

    If using PHP 4.3.5 or less include the following line. If using 4.3.6 or greater, you should remove this line if present.

    session.save_path=c:\tmp    
  6. If you have had previous versions of PHP installed, you had likely moved the PHP system files to in the Windows directory structure. If so, you will have to remove those files. Please review your PHP installation documentation for instructions on removing those files.

  7. If you want to allow template importing, uncomment the following line:
    file_uploads = On
  8. Give the user who will be running the scheduled task, modify rights to:
    1. If using PHP 4: c:\php\mibs\.index 
    2. If using PHP 5: c:\php\extras\mibs\.index

Configure the Webserver (Apache)

  1. Make sure you have stopped any IIS web servers before you proceed with Apache installation.

  2. If you are using Apache 1.3.x, installation of PHP 5 is not recommended. If using PHP 4, add the following lines to your httpd.conf file in the c:\apache\conf directory:

    LoadModule php4_module c:\php\sapi\php4apache.dll
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php
  3. If you are using Apache 2.x, add the following lines to your httpd.conf file in the c:\apache2\conf directory:

    If using PHP 4, then add the following lines:

    LoadModule php4_module c:\php\sapi\php4apache2.dll
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php

    If using PHP 5, then add the following lines:

    LoadModule php5_module c:\php\php5apache2.dll
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php

Configure the Webserver (IIS)

  1. Start the Internet Information Services (IIS) Manager, right click on Default Web Site (in most cases) and select Properties.

  2. Under the Home Directory tab, select Configuration and click Add. Browse to the path of php4isapi.dll or php5isapi.dll, and type in .php as the extension.
    IIS6: Enable All Verbs and Script Engine.

  3. Under the ISAPI Filters tab, click Add and browse to the php4isapi.dll or php5isapi.dll file. Name the filter "php" and click OK.

  4. Under the Documents tab, add index.php to the top of the list.

  5. If using IIS6, go to Web Service Extensions and add a new Web Service Extension.  Name the extension "php", click Add and browse to the php4isapi.dll or php5isapi.dll file,  enable Set Extension status to Enable, and click OK.
  6. Under the Default Web Site, right click on Cacti and select Properties.
  7. Under the Directory tab, click the Write checkbox..
  8. Give the IUSR_XXXX and IIS_WPG users read & execute permissions to the file %windir%\system32\cmd.exe.  They will also need read permissions on <web root>/cacti/ and its subfolders.
  9. IIS6: Give the IIS_WPG user modify permissions to the folders /cacti/log and /cacti/rrd.
  10. Completely stop and start the IIS service using the following commands:

    net stop iisadmin
    net start w3svc

Install Cygwin (optional)

  1. Installing a single instance of Cygwin, and using it for all applications that require it is recommended so you do not have different versions of the Cygwin dlls laying around on your system, which can cause conflicts.
  2. Run setup.exe you previously downloaded.
  3. Once you reach the portion of setup entitled Select Packages, install the following:
    Base (whole thing)
    Libs
    libart_lgpl
         libfreetype26
         libpng12
         zlib
    Utils
    patch
    Web
    wget
  4. Add c:\cygwin\bin to your system path.
  5. Move setup.exe to c:\cygwin for future use.

Install RRDTool

  1. If you have Cygwin installed, remove the DLL files from the c:\rrdtool directory.

Configure MySQL

  1. Start MySQL by running c:\mysql\bin\winmysqladmin.exe.

  2. Set a password for the root user

    shell> cd mysql\bin
    shell> mysqladmin --user=root password somepassword
    shell> mysqladmin --user=root --password reload
  3. Create the MySQL database:

    shell> mysqladmin --user=root --password create cacti
        
  4. Import the default Cacti database:

    shell> mysql --user=root --password cacti < c:\apache2\htdocs\cacti\cacti.sql
        
  5. Optional: Create a MySQL username and password for Cacti.

    shell> mysql --user=root --password mysql
    mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
    mysql> flush privileges; 
  6. If you're running MySQL 4.1 then you will need to apply the old password trick for user authentication to work with Cacti.
    Stop the MySQL service and add the following to Start Parameter field. Start it again once it has been added.
    --old-passwords

    You will also need to update the cactiuser account with the old password style:
    shell> UPDATE mysql.user SET Password = OLD_PASSWORD('cactipw') WHERE Host = 'localhost' AND User = 'cactiuser';
    mysql>
    FLUSH PRIVILEGES;
  7. If you're running MySQL 5, then you will need to run it in compatibility mode by specifying the following in the Start Parameter field for the MySQL service:
    --sql-mode=MYSQL40

Install Net-SNMP

  1. If you plan to use any hosts with SNMP v2c support, you must download and install the Net-SNMP libraries. Net-SNMP provides installers to install their product. However, caution must be taken not to use long file names as Cacti does not support them in this version. We suggest you install Net-SNMP in a directory such as c:\net-snmp.

Configure Cactid
  1. Modify the cactid.conf file in c:\cactid to include the following statements.

    DB_Host 	IP_Address or Hostname (not localhost)
    DB_Database cacti
    DB_User cactiuser
    DB_Password cactipw

    All other pre 0.8.6 settings are obsolete. Cactid may not complain if you leave them in, but they are not longer required. Cactid now comes with a binary distribution. Therefore, a basic installation of Cygwin is not longer required, but suggested to help maintain dll version conflicts.

  2. If you have Cygwin installed, remove the DLL files and the SH.EXE file from the c:\cactid directory.

Configure Cacti
  1. Edit <web root>/cacti/include/config.php and specify the MySQL user, password and database for your Cacti configuration.

    $database_default = "cacti";
    $database_hostname = "localhost";
    $database_username = "cactiuser";
    $database_password = "cactipw";
  2. Point your web browser to:

    http://your-server/cacti/

    Log in the with a username of admin and password of admin. You will be required to change this password immediately.

    Once logged in, you must go to Settings->Paths and verify/update your paths to point to the correct locations. Recommended examples are posted below.  If you plan on using Cactid, then it is very important that your all your paths and scripts use forward slashes.

    PHP Binary Path:

    If using PHP 4, you should change this to:

    c:/php/php.exe

    If using PHP 5, you should change this to:

    c:/php/php.exe

    RRDTool Binary Path:

    c:/rrdtool/rrdtool.exe

    RRDTool Default Font Path:

    c:/windows/fonts/arial.ttf

    RRDTool Version:

    Select the appropriate version


    SNMPGET, SNMPWALK Paths:

    c:/net-snmp/bin/snmpget.exe
    c:/net-snmp/bin/snmpwalk.exe

    Cacti Logfile Path:

    c:/mycacti/website/cacti/log/cacti.log

    Cactid Path:

    c:/cactid/cactid.exe
  3. Click on Devices. Delete Localhost, since it's set up to use the Linux host template.  In the upper right corner, click on Add.   Fill in the following information and then click Add.
    Description: localhost
    Hostname: localhost
    Host Template: Windows 2000/XP
  4. You should now be looking at the localhost device screen.  Right under it's name, there should be some SNMP information listed, if not you should double check the SNMP settings on the server and firewall settings.  In the upper right-hand corner, click on Create Graphs for this Host. On the following screen, select a disk partition and network interface.  At the bottom of the page, click on Create.
  5. Log into the user account you'll be using  for the scheduled task and  verify starting a Cacti polling cycle works.  Do this by running the following from the command prompt: 
    php c:\<web root>\cacti\poller.php

    The output should look something like this:
    C:\>php c:\inetpub\wwwroot\cacti\poller.php
    OK u:0.00 s:0.06 r:1.32
    OK u:0.00 s:0.06 r:1.32
    OK u:0.00 s:0.16 r:2.59
    OK u:0.00 s:0.17 r:2.62
    10/28/2005 04:57:12 PM - SYSTEM STATS: Time:4.7272 Method:cmd.php Processes:1 Threads:N/A Hosts:1 HostsPerProcess:2 DataSources:4 RRDsProcessed:2
    After this has ran once, you should have cacti.log in /cacti/log/ and rrd files in /cacti/rra/.
  6. You are going to need to schedule a task while logged on as an Administrator account, so poller.php can run every 5 minutes. Make sure the Task Scheduler service is started and follow the steps below to begin.

    1. Select Start --> Settings --> Control Panel and double click on Scheduled Tasks.

    2. Double click on Add Scheduled Task.

    3. Click Next and Browse on the following screen. Find c:\php and select php.exe. If using PHP 5 with Cacti 0.8.6f or earlier, use php-win.exe instead. Choose Daily on and click Next.

    4. Click Next again without changing the time or date settings.

    5. When entering a username and password make sure the user has modify access to the following directories:

      c:\<web root>\cacti\rra\
      c:\<web root>\cacti\log\

      Make sure the user has read, and execute access to the following directories:

      c:\php\
      c:\<web root>\cacti\
    6. Click Next and Finish to close the wizard.

    7. Right click on the task you just created, and select Properties.

    8. Select the Schedule tab.

    9. Make sure Daily is selected and click the Advanced button.

    10. Check the Repeat checkbox, set the repetition for every 5 minutes, set the duration for 24 hours, and check the If the task is still running, stop it at this time checkbox.

    11. Click Ok

    12. In the Run textbox enter the following text making sure to use the appropriate paths.

      c:\php\php.exe c:\<web root>\cacti\poller.php

      The start in box should say c:\<web root>\cacti.

Apply Patches
  1. There are two methods of applying patches to Cacti:
    1. If you have Cygwin installed, then the patch instructions which use wget and patch, will work. 
    2. The other method requires you to visit http://www.cacti.net/downloads/patches/<cacti version>/pre-patched/ and manually download and replace the patched files.
  2. You might need to reapply file/folder security on the files patched. Double check they are correct.
Tweaking

There are several things you can do to speed up your Cacti web server.  It's suggested that you only apply these after you have a fully functional Cacti installation.
  1. Switch the polling agent in Cacti from cmd.php to Cactid.exe.  Go to Settings | Poller | Type.
  2. Install the Zend Optimizer for PHP.  
  3. Set up the query cache in MySQL.  Read about how to properly configure the settings.  You will need to stop the MySQL service when you edit c:\mysql\my.ini and put in the following:
    #The memory allocated to store results from old queries.
    query_cache_size=16M
    #Don't cache results that are bigger than this.
    query_cache_limit=1M
    #Query cache type to use.
    query_cache_type=1
  4. Install FastCGI, which can offer x4 to x8 improvement (for IIS users at least).
  5. An extensive list of other optimizations for PHP and MySQL can be found over at phplens.com.