OC ./occ Call to undefined function



Steps to reproduce

  1. sudo -u www-data ./occ

Expected behaviour

normal feedback from ./occ when no arguments are given

Actual behaviour

PHP Fatal error: Call to undefined function OC\App\simplexml_load_file() in /var/www/owncloud/lib/private/App/InfoParser.php on line 41

Server configuration

Operating system:
Linux XXXXX 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
(which is ubunt 16.04)

Web server:
Apache Server Status for XXXXX (via XXXXXX)

Server Version: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g
Server MPM: prefork
Server Built: 2017-09-18T15:09:02


Current Time: Sunday, 03-Dec-2017 12:23:45 CET
Restart Time: Sunday, 08-Oct-2017 21:01:49 CEST
Parent Server Config. Generation: 59
Parent Server MPM Generation: 58
Server uptime: 55 days 16 hours 21 minutes 56 seconds
Server load: 0.11 0.20 0.18
Total accesses: 2148012 - Total Traffic: 222.9 GB
CPU Usage: u3015.96 s849.26 cu0 cs0 - .0803% CPU load
.446 requests/sec - 48.6 kB/second - 108.8 kB/request
1 requests currently being processed, 9 idle workers


Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process


PHP version:

ownCloud version: (see ownCloud admin page)

Updated from an older ownCloud or fresh install:
older (at least 8)

Where did you install ownCloud from:
via ubuntu repository deb https://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/ /

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
paste the results into https://gist.github.com/ and puth the link here.

like ./occ, the admin login doesn't work anymore. At some point I updated to owncloud which only allowed php7 (was that OC8 or OC9 already?). Since that is/was non-standard in Ubuntu 16, it took quite some effort to get php7 installed next to php5, which ubuntu did not want to un-install. In parallel, I now have the complication of having an original mysql-based setup of the server and (without me being aware) a new sqlite3 database in the data directory.

I am basically stuck, because any malfunctioning (admin login, ./occ, file locks) could be caused by the php5->php7 transition, the mysql->sqlite3 transition or any of the OC 8>9>10 transitions that were either 'automatic' or via the repository or via changing the repository name when going from ubuntu 15 to 16 (for instance).

The system starts to have more and more file locks and the current 'keeping the system in the air' way of 'maintenance' makes OC less and less usable for all users. Before I ruine everything, maybe fixing ./occ would help me to identify what is broken and what not.

Any help on how to get out of this deadlock would be appreciated. I acknowledge the messy status of the system at the moment.

The content of config/config.php:

Log in to the web-UI with an administrator account and click on
'admin' -> 'Generate Config Report' -> 'Download ownCloud config report'
This report includes the config.php settings, the list of activated apps
and other details in a well sanitized form.


If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your ownCloud installation folder

*ATTENTION:* Do not post your config.php file in public as is. Please use one of the above
methods whenever possible. Both, the generated reports from the web-ui and from occ config:list
consistently remove sensitive data. You still may want to review the report before sending.
If done manually then it is critical for your own privacy to dilligently
remove *all* host names, passwords, usernames, salts and other credentials before posting.
You should assume that attackers find such information and will use them against your systems.

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your ownCloud installation folder.

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your ownCloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';

Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

Client configuration


Operating system:


Web server error log

Insert your webserver log here

ownCloud log (data/owncloud.log)

Insert your ownCloud log here

Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log 
c) ...


It looks to my that you havn't followed https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#install-the-required-packages and you're missing the php7.0-xml package.


Dear tom42,

I think I did:

sudo apt install php7.0-xml
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-xml is already the newest version (7.0.22-0ubuntu0.16.04.1).

at least it's the current version of ubuntu16.04


It looks to me that something got wrong / is miss-configured in your PHP configuration and that module isn't loaded correctly.


When I run php7.0 -i, it gives me several indications that "things are allright":

Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,

.... and later:

DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.9.3
HTML Support => enabled

... and later:


json support => enabled
json version => 1.4.0


libXML support => active
libXML Compiled Version => 2.9.3
libXML Loaded Version => 20904
libXML streams => enabled

... and later


WDDX Support => enabled
WDDX Session Serializer => enabled


XML Support => active
XML Namespace Support => active
libxml2 Version => 2.9.3


XMLReader => enabled

I know little of php (7); is there a way to test the XML part, separate from OC?


My php -i output has the following:

Simplexml support => enabled

I think this is probably the one which is required for the "simplexml_load_file" in your initial posted output.


This is enabled too, but I get an extra 'revision' line:


Simplexml support => enabled
Revision => $Id: b8b5c37931a53e50a937c0aef2a26d351e173215 $
Schema support => enabled

Do you get such a 'revision' line below too?


Could this be the problem: apt installs php7.0-xml instead of php7.0-simplexml:

sudo apt install php7.0-simplexml
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.0-xml' instead of 'php7.0-simplexml'
php7.0-xml is already the newest version (7.0.22-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


Anyone an idea?

The error relates to simple_xml in php7.0, but I do not know how to proceed debugging.

I have checked that:

sudo a2dismod php5: Module php5 already disabled

sudo a2enmod php7.0: Module php7.0 already enabled

sudo service apache2 restart

sudo -u www-data /var/www/owncloud/occ:

PHP Fatal error: Call to undefined function OC\App\simplexml_load_file() in /var/www/owncloud/lib/private/App/InfoParser.php on line 41

ls /etc/apache2/mods-enabled/ | grep php

I'm stuck...


The occ command is a PHP file, not a batch script, so you need to run it with PHP. See: https://doc.owncloud.org/server/latest/admin_manual/configuration/server/occ_command.html#run-occ-as-your-http-user


Yes, this output gave another idea. This looks to me like a typical user error. Above you had used php7.0 to post the output and proved that simplexml is installed, but every PHP script is always using the "php" binary which probably defaults to PHP 5 on your system.


thanks both for the reply.

Indeed, the file /var/www/owncloud/occ has:

#!/usr/bin/env php

on the first line and this will find php5, because /usr/bin/php links to /etc/alternative/php (in Ubuntu at least), which, in turn points at /usr/bin/php5.6 (on my computer).

server:/etc/alternatives> ll php
lrwxrwxrwx 1 root root 15 Jun 12 22:29 php -> /usr/bin/php5.6*

so, I changed it to point at php7.0:

server:/etc/alternatives> sudo ln -fs /usr/bin/php7.0 php

that SOLVES the problem and I can now run ./occ in /var/www/owncloud since the 'php' inside now will find php7.0

(still needs to be run as user www-data, though).