Recompile php with mcrypt: Difference between revisions

From SlackWiki
Jump to navigation Jump to search
(Copy from old, had no category, placed in Tutorials)
 
(removed note about editing slackbuild)
 
Line 10: Line 10:
Go to a Slackware mirror and download Pat's Slackbuild directory for php from the source/n directory.  I used  
Go to a Slackware mirror and download Pat's Slackbuild directory for php from the source/n directory.  I used  


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


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/.
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).
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).


=== Edit php.SlackBuild ===
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):


You will need to add a "--with-mcrypt=" flag to the configure command in php.SlackBuild. Since you already have mcrypt installed, you can use
<code># BUILD=3_<your initials> sudo ./php.SlackBuild</code>
 
<code>--with-mcrypt=`which mcrypt`</code>
 
Remember to add the slash at the end of the line.  I positioned this flag second to the bottom.  The position of the flag only matters for your ability to find it next time, order will not affect the build process.  SlackBuilds customarily have the "--build=" flag at the bottom, so I left it where it was.


=== Upgrade PHP ===
=== Upgrade PHP ===

Latest revision as of 16:55, 5 October 2009

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.