Note that you can also get this error if your PHP library doesn't have the "other" directory opening permission. In my particular case, I noticed this when using php -l
to syntax check a script in my text editor. This meant that since my account was called "volomike", that account didn't have permission to run the libraries that the php
command relied upon.
For instance, on Ubuntu 14.04, I had PHP5 installed automatically into the path /usr/lib/php5/20121212+lfs
. However, because I was working in C++ in building some shared objects, I messed around with the directory permissions and screwed things up such that non-root accounts did not have the directory execute (directory open) permissions to view /usr/lib/php5/20121212+lfs
. So, I typed the following command to rectify that problem:
sudo chmod o+x /usr/lib/php5/20121212+lfs
.
Now when I do php -l example.php
as a non-root user, it never gives me this "Unabled to load dynamic library" problem anymore.