Recompile php with mcrypt

From SlackWiki
Jump to navigation Jump to search

PhpMyAdmin (available at SlackBuilds.org) works well when you compile PHP with the mcrypt extension. After installing PhpMyAdmin, you may see a warning that it cannot find the mcrypt extension. Unfortunately the official Slackware package does not include this extension. Recompiling PHP is necessary, as is enabling the mcrypt.so extension in /etc/httpd/php.ini. The first step is a little tricky, since compiling PHP requires a little trick: you must compile alpine during the PHP build. It is fairly simple once you have things in place, but this tripped me up when I first tried to recompile PHP.

Install mcrypt and libmcrypt

mcrypt is available from SlackBuilds.org. First build and install mcrypt and libmcrypt before compiling PHP.

Recompile PHP

Go to a Slackware mirror and download Pat's Slackbuild directory for php from the source/n directory. I used

# wget --mirror <mirror>/n/php

to download the whole directory. You will also need to download the alpine/ directory into the parent of the newly-created php/. In other words, you should have a parent directory with both php and alpine. For example, mine is ~/SlackBuilds/n, where I have two subdirectories: one for alpine/ and one for php/. An alternative to wget is to use a file manager capable of ftp with drag and drop, such as Nautilus.

Be sure to chmod +x both the alpine and php SlackBuilds before attempting to build. If you don't, things may go for quite a while depending on the speed of the machine you're building on before you get an error (and you will get an error).

The official PHP SlackBuild includes a configure flag for mcrypt, so there is no need to edit the SlackBuild. You may want to specify a BUILD variable on the command line, so the package does not appear to be official (it is not official):

# BUILD=3_<your initials> sudo ./php.SlackBuild

Upgrade PHP

Install the new package with upgradepkg. Keep in mind that you will need to repeat this process whenever there is a security alert for php. In that case, download the new source, update the VERSION variable, recompile and upgrade. For this reason, I've kept ~/SlackBuilds/n the way it is with alpine and php subdirectories.

Configure PHP

Configuring PHP to use mcrypt is easy: add the line

extension=mcrypt.so

to /etc/httpd/php.ini and then restart apache. Now when you log in to PhpMyAdmin, you should no longer see the warning about mcrypt.