I am trying to deploy some PHP scripts on a webserver which is already hosting a live website. In my local development environment the scripts run fine. However, on the server they do not run, and I have traced the problem via the apache error logs to PHP not being able to create a new DOMDocument object. I believe I have narrowed this to a line in the “Configure Command” settings in phpinfo(). In that section, I see --disable-dom, as well as --without-curl. Both of these should be enabled in order for my script to work properly.
If I can enable these features within my script, that would be great. Otherwise I might need to recompile php, but I’m loathe to do that unless it’s absolutely necessary. Is there some way I can override these settings in php.ini, in the script itself at runtime, or through some other method?
Edit: if it helps, the PHP version is 5.3.3-14.el6_3 and it appears that it was installed via yum. OS is Scientific Linux 6.3.
The answer is here:
https://serverfault.com/questions/66189/how-to-enable-dom-without-recompiling-php
Turns out I just needed to restart Apache in this case after running
yum install php-xmlEDIT: Here’s a more thorough overview of what happened here:
PHP 5.3.3 was installed via Scientific Linux’s
yum. by default it installed from the @sl-security repo. This resulted in a compile command that excluded features like curl and DOMDocument.To enable these features, I ran
yum install php-xml. I then verified that the appropriatedom.somodule was loading by inspecting thedom.inifile in/etc/php.d/.What I didn’t realize was that I needed to restart Apache to make the changes take effect. On this particular system, this was achieved by typing the following:
service httpd restartAt this point I was able to use the PHP DOMDocument class.
The “compile command” in phpinfo() just indicates that PHP was compiled without the modules. These modules could be added after the fact using
yum. I imagine that without yum, one would just need to download the appropriate .so module file and edit php.ini to make sure that module was included.But of course, the key point is that for any of the changes to take effect, you have to restart Apache. That part was not obvious to me!