Monday 29 September 2008

Failed opening required 'XML/RSS.php' - Solved

Sometimes, it takes a small problem to make one realise how little he actually knows. I personally know a fair bit about all sorts of technology, ranging from networks, to development to integration; however I haven't really had much experience with Linux. It's partly because most of the services I use are nicely packaged, but also because I'm mostly grounded in a Microsoft world in my day-to-day job. But it was great to find that thanks to the Internet I can research a problem and solve problems too.

Last night I started dealing with a problem were a PHP component I had written some time back has stopped working after a server move. Looking through the logs I could see that the error I was getting was:

PHP Fatal error: require_once() [function.require]: Failed opening required 'XML/RSS.php' (include_path='.:/usr/share/pear:/usr/share/pear/XML') in /var/www/vhosts/xxx/httpdocs/site_elements/register.php on line 6

Okay I thought, it must be that the PEAR component I needed wasn't available. PEAR stands for PHP Extension and Application Repository and is a framework and distribution system for reusable PHP components. I needed the RSS component which was used by my code. I eventually got myself SSH access to the box and deployed the components (also finding out that I needed a couple of prerequisite packages). The way you do this is:


pear install XML_Parser
pear install XML_Tree
pear install XML_RSS


This downloads and deploys the required components for you into /usr/share/pear. But my code still wouldn't run.

Eventually I found out that this was becuase PHP was running in "safe mode". Safe mode is a way to protect PHP from different users on the same server, but this was a dedicated server so I didn't really need it on. One thing that safe mode does is that it stops you from including files from other directories. This was coupled with another parameter "open_basedir" that limits the files that can be opened by PHP to a specified directory tree (which didn't include /usr/share. so that needed to be rectified too.

I did my reading, open SSH again and proceeded to update my php.ini file to adjust these settings. I saved it, tried the site again. Still exactly the same error.

Reading a bit more around the subject, I discovered that each website also has it's own httpd.conf file which overrides php.ini, so the search was on once again to find more of these settings. Sure enough, I found this configuration file, modified it, saved it and tried the site again. Still the same error.

At this point I ran out of things to try, so like all techies I figured, maybe I need to restart Apache to read the settings again. You know, the traditional "turn it off and turn it back on again". Being a noob when it comes to Linux I logged into my control panel, stopped the site and started it again. Still the same error.

Eventually I got to the bottom of it. Stopping and starting the site didn't quite restart the service the way I wanted it to. The REAL way to do it is with the following command (again in SSH)

service httpd graceful


And would you know it .. the problem is now solved!

I thought I'd document the process here for two reasons. If you're trying to solve this problem you may find these steps useful. You may need this if you go into fixing people's technical problems, there may be a franchise opportunity there somewhere. And I'm pretty sure I'll need to do this again one day, so it's always a good idea to write it down!


(continue reading &aquo;)

No comments: