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:
vi /etc/yum.conf
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 php-xml
and libxslt
(depending on your architecture libxslt.i686
or libxslt.x86_64)
.
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:
vi /usr/local/lib/php.ini
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.
https://www.domsammut.com/?p=781#comment-2031
#Chris Brady
This was helpful to read, but for me with Centos 6, php 5.3.3 this did not work.
After several other tries (and failures but with each learned something new) what worked for me was …
yum install php-xml
This
1. installed the xsl.so in the correct /usr/lib64/php/modules directory
2. Also installed other .so files similarly including dom.so
3. identified libxslt as a dependency and installed it
4. Added the necessary .ini files (to /etc/php.d) to match each php extension .so file
https://www.domsammut.com/?p=781#comment-1963
#Gautam
good blog but do not work for centos7 from godaddy
https://www.domsammut.com/?p=781#comment-1965
#Dom Sammut
Hey Gautam,
This tutorial was written for CentOS 6, but it shouldn’t be drastically different for CentOS 7. I’d be happy to try and help if you could provide some more detail around the issue(s) you’re encountering.
Cheers
Dom
https://www.domsammut.com/?p=781#comment-1947
#Bell
Hi Dom,
This is Bell. I follow your guide to install the xsl extension, but seems that this guide doesnt work for me. would you please help?
https://www.domsammut.com/?p=781#comment-1948
#Dom Sammut
Hi Bell,
I’ll need some information like server setup, existing software packages, operating system and steps and trouble shooting you’ve attempted so far.
Cheers
Dom
https://www.domsammut.com/?p=781#comment-219
#misaelrag
when I tried to copy, the terminal shows cp: cannot stat `/usr/lib64/php/modules/xsl.so’: No such file or directory
In centos where are the folder? :C
https://www.domsammut.com/?p=781#comment-220
#Dom Sammut
Can you confirm that xsl.so file is actually present in that directory. Also ensure that there are no typos or any other discrepancies when entering the command.
Additionally, when you ran:
find / -name "xsl.so"
What were the paths for the files that were listed?
https://www.domsammut.com/?p=781#comment-242
#upsin
nothing :(
https://www.domsammut.com/?p=781#comment-243
#Dom Sammut
What happens when you run
yum --disableexcludes=main install libxslt.i686
?https://www.domsammut.com/?p=781#comment-244
#upsin
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: s2plmirror02.prod.sdl2.secureserver.net
* extras: s2plmirror02.prod.sdl2.secureserver.net
* updates: s2plmirror02.prod.sdl2.secureserver.net
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
Package libxslt-1.1.26-2.el6_3.1.i686 already installed and latest version
Nothing to do
https://www.domsammut.com/?p=781#comment-245
#Dom Sammut
Hmm okay. What about
yum --disableexcludes=main install libxslt.x86_64
? If that doesn’t work, can you runyum list libxslt
and see what list is returned. If you see an appropriate package there you can try install it. Who’s your hosting provider?https://www.domsammut.com/?p=781#comment-246
#misaelrag
when I run yum –disableexcludes=main install libxslt.x86_64
root@ip-97-74-198-51 [~]# yum –disableexcludes=main install libxslt.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: s2plmirror02.prod.sdl2.secureserver.net
* extras: s2plmirror02.prod.sdl2.secureserver.net
* updates: s2plmirror02.prod.sdl2.secureserver.net
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
Package libxslt-1.1.26-2.el6_3.1.x86_64 already installed and latest version
Nothing to do
—–
yum list libxslt
root@ip-97-74-198-51 [~]# yum list libxslt
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: s2plmirror02.prod.sdl2.secureserver.net
* extras: s2plmirror02.prod.sdl2.secureserver.net
* updates: s2plmirror02.prod.sdl2.secureserver.net
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Installed Packages
libxslt.i686 1.1.26-2.el6_3.1 @base
libxslt.x86_64 1.1.26-2.el6_3.1 @base
https://www.domsammut.com/?p=781#comment-247
#misaelrag
my hosting provider is Goddady U_U
https://www.domsammut.com/?p=781#comment-248
#Dom Sammut
Hmm okay. A couple of questions:
/usr/lib64/php/modules/
and list what’s currently in this directoryphp-config --extension-dir
https://www.domsammut.com/?p=781#comment-249
#misaelrag
https://www.domsammut.com/?p=781#comment-250
#Dom Sammut
In regards to number 3, can you run the following and look for a similar path to php modules
find / -name modules -type d
orfind / -name php -type d
. In regards to number 4, yes/usr/local/lib/php/extensions/no-debug-non-zts-20100525
.https://www.domsammut.com/?p=781#comment-47
#Bruce Wang
thank you very much for this guide!
but it’s doesn’t work when i finished, i copied the “xsl.so”, edited “php.ini”, and restart server, and tried many other methods and many times, it still not work.
can you help me? please…
https://www.domsammut.com/?p=781#comment-49
#Dom Sammut
No problems. Can you confirm you’ve copied the xsl.so to the php extension directory. If you have a screenshot or link to view more information that would be great!