An automated Bash script to compile, install, configure, and verify the PECL timezonedb extension across all installed PHP versions on a DirectAdmin server.
- Auto-Detection: Automatically scans
/usr/local/php*to detect all installed PHP versions. - Smart Installation: Attempts
pecl upgrade timezonedbfirst, falling back topecl install -fif required. - Permission Management: Sets explicit
0755permissions ontimezonedb.sowithin the extension directory to prevent loading issues. - Idempotent Configuration: Safely adds
extension=timezonedb.soto10-directadmin.iniwithout creating duplicate entries. - Service Management: Gracefully restarts matching
php-fpmservices (e.g.,php-fpm74,php-fpm83). - Post-Install Verification: Tests each PHP binary and outputs the current date, active timezone, and TimezoneDB version.
- Linux server with DirectAdmin installed.
- Root privileges (
sudo/root). - PECL utility available for installed PHP versions.
Clone this repository or download the script directly:
git clone https://github.com/MrAriaNet/DirectAdmin-TimezoneDB-Auto-Updater.git
cd DirectAdmin-TimezoneDB-Auto-Updater
Grant execution permissions to the script:
chmod +x update_timezonedb.sh
Execute the script with root privileges:
sudo ./update_timezonedb.sh
For every detected directory matching /usr/local/php*, the script performs the following steps:
- Build & Upgrade: Executes PECL upgrade/install.
- Set Permissions: Retrieves the PHP extension directory path dynamically via
php-config --extension-dirand applieschmod 0755ontimezonedb.so. - Configure INI: Ensures
extension=timezonedb.sois present in/usr/local/phpXX/lib/php.conf.d/10-directadmin.ini. - Restart FPM: Restarts
php-fpmXXviasystemctl. - Verify: Executes inline PHP CLI code:
echo 'Time: ' . date('Y-m-d H:i:s T') . PHP_EOL .
'Timezone: ' . date_default_timezone_get() . PHP_EOL .
'TimezoneDB: ' . timezone_version_get() . PHP_EOL;To keep your server's PHP timezone database updated automatically, you can add a monthly cron job:
# Run on the 1st day of every month at 3:00 AM
0 3 1 * * /usr/local/bin/update_timezonedb.sh > /dev/null 2>&1
This project is licensed under the MIT License.