So you’ve got your CentOS server ready to roll. Go to install your PHP application, in my case, Symphony CMS, only to get a nice little message telling you that you need to install the PHP XSLT extension.
Don’t despair, this should only take five minutes or so (from when you started reading this post, not the two hours prior!)
Please note this solution requires that you have shell (sudo, preferably) access to your server.
First thing to do is run:
sudo yum update
This will update all existing installed packages on your sever.
The next thing to do is run the following:
yum --disableexcludes=main list installed
This will show you all installed packages including ones that might be excluded from general
yum commands in your yum configuration file.
You can check to see what is excluded in this file by running the following:
Depending on your hosting provider it will look something similar to this:
[main] exclude=apache* bind-chroot courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* perl* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail* tolerant=1 errorlevel=1 cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
Note in the example file above the php packages are hidden on the second line.
The package(s) you’ll need are
libxslt (depending on your architecture
To install these packages perform the following command (replacing libxslt.i686 with the required packages):
yum --disableexcludes=main install libxslt.i686
Once you’ve installed these you’ll need to find the following:
find / -name "xsl.so"
This searches your entire server for the xsl extension you’ve installed. Note the directory to this file. We are going to copy the file to your extension directory. The quickest way to find this is to
phpinfo() the information.
Create a php file and add the following line of code and save it to a web accessible directory.
<?php phpinfo(); ?>
When you view the file in the browser, look for the following line:
Note this line down and then combine into the folowing command:
cp -i /usr/lib64/php/modules/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
This will copy the extension from the original path to the extension directory.
Now you need to add it to the php.ini file. You can find the location of this file in the
phpinfo file you previously created.
Now you’ll need to edit it:
Navigate the file until you find the section:
;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;;
After this you shoud see a few lines down:
; Directory in which the loadable extensions (modules) reside.
Behold, the the calling of extensions. You should see some existing calls such as
extension = "pdo.so"
You’ll just need to add a line in here:
extension = "xsl.so"
Once you’ve done that. Save the file.
We’ll now need to reboot apache.
service httpd restart
That’s it. You should now have your XSLT extension installed and ready to use in PHP.
Please note that this is just my experience on getting the extension installed and that server configs vary widely between hosting providers. Happy to help if you have any questions though.