Fixing cacti php timezone installation error

Hello everyone !

When installing  some of the new versions of cacti you may come across these below 2 PHP errors related to a timezone which will prevent you from installation CACTI

This is a simple fix that involves editing the php.ini for PHP and php.ini file for PHP CLI

cacti installation screen

 

the PHP.ini files are located in these 3 directories on a Debian based system

 

/etc/php/7.0/fpm/php.ini
/etc/php/7.0/cli/php.ini
/etc/php/7.0/apache2/php.ini

 

if you are having a hard time finding your php.ini files run the following command to search for them

find / -name php.ini

 

Now once you have located the files we need to add the timezone to them to fix this error

see the below example on the php.ini file for apache

root@ubuntu:~# cat /etc/php/7.0/apache2/php.ini | grep timezone
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
root@ubuntu:~#

 

we will need to uncomment the date.timezone directive and add our timezone in my case it’s America/Toronto

you can find a list of all supported PHP timezones here http://php.net/manual/en/timezones.php

using your choice of text editor edit /etc/php/7.0/apache2/php.ini  to below
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = “America/Toronto”

After you finish editing the file you must restart the apache process either by ( service apache2 restart) or on systemd systems ( systemctl apache2 restart)

root@ubuntu:~# service apache2 restart
root@ubuntu:~# service apache2 status
● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf

Now let’s check the installer  to see if the error has cleared

cacti installtion screen

As you can see the error changed to Passed and the timezone matches what I set it to in php.ini

now all you have to do is the same steps for  /etc/php/7.0/cli/php.ini

 

Hope this helps!

 

 

 

 

 

 

 

 

 

 

 

12 thoughts on “Fixing cacti php timezone installation error

    1. I’ts not working for me with PHP 7.2 interesting… Glad you posted this. I thought it was me. I’ll keep digging.

  1. Hi dear,
    I have the same issue. I was try solve this of differents way, but the issue continue.
    time zone in the php.ini is set and the database too.

    MariaDB [(none)]>
    MariaDB [(none)]> select @@global.time_zone;
    +——————–+
    | @@global.time_zone |
    +——————–+
    | America/Lima |
    +——————–+
    1 row in set (0.00 sec)
    MariaDB [(none)]> exit
    Bye
    [root@cacti ~]# more /etc/php.ini |grep date.timezone
    ; http://php.net/date.timezone
    ;date.timezone = America/Lima
    [root@cacti ~]#

    As well tried with this, but show this message: ERROR 1062 (23000) at line 17: Duplicate entry ‘MET’ for key ‘PRIMARY’

    [root@cacti ~]# cd /usr/share/mysql/
    [root@cacti mysql]#
    [root@cacti mysql]#
    [root@cacti mysql]#
    [root@cacti mysql]# ls -ltr |grep mysql
    -rw-r–r– 1 root root 1210 sep 8 08:25 mysql_to_mariadb.sql
    -rw-r–r– 1 root root 792 sep 8 08:25 mysql_test_db.sql
    -rw-r–r– 1 root root 10411 sep 8 08:25 mysql_test_data_timezone.sql
    -rw-r–r– 1 root root 27622 sep 8 08:25 mysql_system_tables.sql
    [root@cacti mysql]#
    [root@cacti mysql]#
    [root@cacti mysql]#
    [root@cacti mysql]# mysql -u root -p mysql < mysql_test_data_timezone.sql
    Enter password:
    ERROR 1062 (23000) at line 17: Duplicate entry 'MET' for key 'PRIMARY'
    [root@cacti mysql]#
    [root@cacti mysql]#

    Please, help me to solve this one.

    BR.

  2. Thanks for the tip. This fixed the timezone errors. I just had to edit the 7.3 version files:
    /etc/php/7.3/cli/php.ini
    & /etc/php/7.3/apache2/php.ini
    now just looking why 2 required packages didn’t install and should be good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.