PHP “Invalid library” error related to ‘mcrypt.so’

While I was compiling PHP from source to install the latest PHP version 5.5.4 on the OSX (10.7.5 Lion). (BTW, try not to do this at home because this can be a tedious process! )

I got the following error:

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) ‘mcrypt.so’ in Unknown on line 0

My php.ini is from previous version, and it is located at /etc/php.ini (you can find your php.ini by running “php –ini” in the command line. ). Since I compile the mcrypt.so seperately beofre, I have added the following line in my php.ini:

But this time, I compiled mcrypt with php, so I keep getting this error everytime I run “php” from the command line, until I finally removed it

And the error is gone, turns out I have compiled the module with PHP so I don’t need to load this as extensions. To make sure you really have mcrypt loaded, run this and you should see “mcrypt” as result