Category Archives: Server

Pydio PHP cloneNode() error

Last friday, after updating from PHP 5.5.6 to PHP 5.5.7, Pydio (formerly AjaXplorer) wasn’t working anymore.

I’m using nginx 1.4.4 + PHP 5.5.7 and when I tried to open Pydio I only got 502 Bad Gateway or the following error:

2013/12/13 12:40:24 [error] 21628#0: *85 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function cloneNode() on a non-object in /var/www/site.nl/core/classes/class.AJXP_Plugin.php on line 276" while reading response header from upstream, client: 193.x.x.x, server: site.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.nl"

I have been searching for a solution for hours, but even installing a fresh copy of Pydio wouldn’t work (I couldn’t get to the installer page, same error).

After a long time searching on Google and the PHP changelog I asked for help on the Pydio forums. Someone told me to downgrade PHP, but that’s the last thing I would try.

Pydio still didn’t work after trying many things. Then, after looking at the PHP changelog again, I disabled PHP’s built-in opcache, and Pydio was working again!

So, if you have the same problem, just disable PHP’s built-in opcache. I don’t know if this is a bug in PHP or Pydio, but I’ll just try to enable opcache again in PHP 5.5.8.

Update 08-02-2014 – It seems to work normally again with PHP 5.5.9 (changelog).

TransIP DDNS

Today I made a new PHP script using the TransIP API to update DNS entries. This way it’s possible to automatically update your (dynamic) home IP address for example.

To use this script you need a server with a static IP address and PHP support. If you don’t have a server with a static IP address, free hosting will do the job.

Follow these steps to install this script:

  1. Download the TransIP API to your server
  2. Go to the TransIP CP (My account > API settings)
  3. Enable the API and add your server’s IP address to the list
  4. Add a new Key Pair and copy the key to your clipboard
  5. Edit Transip/ApiSettings.php and set $login and $privateKey (the key you just copied)
    Alternatively you can set this in the script itself, see this comment
  6. Download the script below to your server (dns.php)
  7. Edit the settings in dns.php (domain, key, and records to update)
    This key is used to identify the client, this way the DNS won’t be updated with the IP address of someone else
    Do NOT use the same key as your TransIP API key, the use of a 25 characters long A-Z a-z 0-9 key is recommended
  8. Now, on the client, access dns.php on the server to update the DNS entries
    On Linux you can create a cronjob with the following command (don’t forget to replace the key):
    wget --spider http://example.com/dns.php?key=69l67Le20e819360d3YHO1175

You’re done. You can test if the script works by openening the URL in your browser and then check if the values are updated in the TransIP CP.


<?php
// SETTINGS
// The domain to edit
define('DOMAIN', 'example.com');

// The authentication key
define('KEY', '69l67Le20e819360d3YHO1175');

// The DNS entries to update (name => content)
// This script will NOT add new entries
$newValues = [
  'www' => $_SERVER['REMOTE_ADDR'],
];

// SCRIPT
// Exit if the key does not match
if($_GET['key'] != KEY) exit();

// Include the required files from the API
require_once('Transip/DomainService.php');

// Get the current DNS entries from TransIP
$dnsEntries = Transip_DomainService::getInfo(DOMAIN)->dnsEntries;

// Check every DNS entry
foreach($dnsEntries as $dnsEntry)
{
  // Check if the entry has to be updated and update it
  if(array_key_exists($dnsEntry->name, $newValues)) $dnsEntry->content = $newValues[$dnsEntry->name];
}

try
{
  // Commit the changes to the TransIP DNS servers
  Transip_DomainService::setDnsEntries(DOMAIN, $dnsEntries);
  // Done
  echo 'DNS updated.';
}
catch(SoapFault $f)
{
  // An error occured
  echo 'DNS not updated. ' . $f->getMessage();
}
?>

MySQL UNIX socket

When using phpMyAdmin earlier today I noticed it was connected to MySQL through an UNIX socket.

UNIX sockets are faster than TCP/IP connections and if there is an UNIX socket and a TCP/IP connection available the UNIX socket should be selected by default (when using localhost as host).

However, how can you be sure this is the case?

If you only use your MySQL server locally you can force MySQL to only create a UNIX socket by adding skip-networking to your my.cnf. I also commented out bind-address = 127.0.0.1, just in case.

Restart your MySQL server and check if MySQL is not listening on TCP/IP anymore by executing netstat -a.

Now check if all your websites/applications can still access your MySQL server and you’re done.