Tutorial: How To Fix Php Deprecated And Missing Library Messages

After a recent dist upgrade, I was bombarded with these messages:

PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0

They are two error messages actually. First, comments with ‘#’ are now deprecated, and Second, there is a dynamic library php is trying to load (in this case mcrypt.so) but is not being able to find.

It is important to note that my websites were all working normally, indicating that both these problems were ‘minor’ in the sense that they are mere warnings – but they still need to be attended to of course.

Repairing The # Deprecation Issue

The first step is to investigate what those messages mean. A quick google shows the issue is relatively common and therefore not unique to just myself. The first Google result at Stackoverflow showed this to be the best repair:

find /etc/php5/cli/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;

The command searches for all files ending in *.ini in the configuration directory for php5 on the server. When it finds them it will then use sed, a text manipulation tool, to replace any incidences of ‘#’ with ‘;’.

Repairing the Missing Library Issue

Another quick google shows the second issue to be also common, with this page showing the most relevant hits.

There are two ways to solve this problem. You can either add the missing library via

sudo apt-get install php5-mcrypt

OR remove the references to it, since it is not being used anyway (as indicated by the websites running normally). I chose this option and followed the commands on the same page.

grep -Hrv ";" /etc/php5 | grep -i "extension="

My result:

1

So I just do:

sudo nano /etc/php5/apache2/conf.d/mcrypt.ini

The page opens, and I just add a ‘;’ in front of the extension.

2I

I restart apache:

sudo service apache2 restart

I check if everything is working, and so far no error messages. Which is great because I finally stopped the deluge in my inbox:

3

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.