Adding mcrypt Support to Sun’s CoolStack
October 26th, 2008
A very boring first post - but I thought I’d blog about this since it’s fresh in my mind!
Sun’s Web Stack - CoolStack
We’ve been using Solaris in an ever increasing way here at EveryCity for a while now. Solaris is an excellent operating system for many reasons, and I’ll no doubt be blogging about it plenty in the weeks and months to come. But one of the key areas Solaris currently lags behind Linux with is the availability of well made, precompiled packages of popular open source software. A very large number of servers these days are deployed to run web services, including Apache, PHP, MySQL, Ruby on Rails, etc, and installing this on Linux can be as simple as “yum install apache php mysql”.
So Sun set out to provide a solution to this on Solaris - enter CoolStack. CoolStack has a good selection of software, including:
- Apache HTTP Server
- PHP Hypertext Processor
- MySQL Database
- Perl Scripting Language
- Ruby (Including rubygems and rails)
- Tomcat J2EE/Java Web Server
- Squid Caching Proxy Server
The PHP package includes a good selection of libraries, so you can get started straight out of the box.
Adding mcrypt Support to PHP on CoolStack 1.3.1
One of the things that CoolStack is missing however is the mcrypt extension, which is used in a number of PHP applications, for example PHPMyAdmin. I was surprised this was missed out, as so many others are included. However it’s not too hard to add this ourself. This example is for CoolStack 1.3.1, but assuming the stack doesn’t change too much, the principles should be the same.
Compiling libmcrypt
Head on over to http://sourceforge.net/projects/mcrypt and download the latest libmcrypt source. You’ll need a healthy development environment, which I’m hoping to blog about in a future post (Hint: Grab Sun Studio 11 and put /opt/SUNWspro/bin at the front of your path).
You’ll want to choose a sensible place to install libmcrypt to - since I was producing a package for deployment to other servers, I chose “/opt/libs/libmcrypt”, but where you place this is up to you - “/opt/coolstack” is another suitable PREFIX path.
Let’s now compile and install libmcrypt (Using cc rather than gcc):
unset CC LDFLAGS CFLAGS export CC=cc ./configure --prefix=/opt/libs/libmcrypt --enable-dynamic-loading \ --with-included-algos=cast-128,gost,rijndael-128,twofish,arcfour,cast-256,loki97,rijndael-192,saferplus,wake,blowfish-compat,des,rijndael-256,serpent,xtea,blowfish,enigma,rc2,tripledes make make install
Et VoilĂ ! You now have libmcrypt installed. If your compiler barfs, post a printout of what you get in the comments and I’ll assist if I can.
Compiling the php mcrypt extension
Assuming you have already downloaded, installed and configured CoolStack, all we need to do is fetch two CoolStack source packages. Nip on over to http://cooltools.sunsource.net/coolstack/, click the link to download, and choose “Source” as the Platform.
Download and install CSKruntime_1.3.1_Src.pkg.bz2 and CSKamp_1.3.1_Src.pkg.bz2 - this should place files under /opt/coolstack/src. Now lets compile the mcrypt extension:
cd /opt/coolstack/src/php5/ ./prepare_src cd php-5.2.6/ext/mcrypt /opt/coolstack/php5/bin/phpize ./configure --with-php-config=/opt/coolstack/php5/bin/php-config \ --with-mcrypt=/opt/libs/libmcrypt/ make make install
You can check to make sure the resulting mcrypt.so file is safe to use by doing:
ldd /opt/coolstack/php5/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so
This should not show any “(file not found)” errors.
Finally, add extension=mcrypt.so to /opt/coolstack/php5/lib/php.ini. Restart Apache (svcadm restart http) - phpinfo(); in a php file should now show a happy mcrypt installation :)

Entry Filed under: Compiling Stuff, CoolStack, SAMP, Solaris

12 Comments Add your own
1. hamdi | December 9th, 2008 at 6:22 am
Thanks for this tutorial, I’m looking for this.
2. Alasdair | December 10th, 2008 at 4:08 pm
No problem hamdi! We’ve made a collection of Coolstack related packages - let me know if you’re interested.
3. Murray | January 5th, 2009 at 6:32 am
I am trying to compile libmcrypt and when I run the make command I get the following error.
gmake[3]: Entering directory `/usr/lib/libmcrypt/modules/algorithms’
if /bin/sh ../../libtool –tag=CC –mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../.. -I../../lib -g -O2 -MT 3-way.lo -MD -MP -MF “.deps/3-way.Tpo” -c -o 3-way.lo 3-way.c; \
then mv -f “.deps/3-way.Tpo” “.deps/3-way.Plo”; else rm -f “.deps/3-way.Tpo”; exit 1; fi
gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../.. -I../../lib -g -O2 -MT 3-way.lo -MD -MP -MF .deps/3-way.Tpo -c 3-way.c -fPIC -DPIC -o .libs/3-way.o
In file included from 3-way.c:14:
../../lib/libdefs.h:18:19: ltdl.h: No such file or directory
3-way.c:73: warning: conflicting types for built-in function ‘gamma’
gmake[3]: *** [3-way.lo] Error 1
gmake[3]: Leaving directory `/usr/lib/libmcrypt/modules/algorithms’
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory `/usr/lib/libmcrypt/modules’
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/lib/libmcrypt’
gmake: *** [all] Error 2
Can you make any suggestions. Thanks
4. Andy Fore | January 31st, 2009 at 6:12 pm
When I compile libmcrypt using cc I get the following error:
*** Error code 1
The following command caused the error:
set fnord $MAKEFLAGS; amf=$2; \
dot_seen=no; \
target=`echo all-recursive | sed s/-recursive//`; \
list=’libltdl modules lib src doc’; for subdir in $list; do \
echo “Making $target in $subdir”; \
if test “$subdir” = “.”; then \
dot_seen=yes; \
local_target=”$target-am”; \
else \
local_target=”$target”; \
fi; \
(cd $subdir && make $local_target) \
|| case “$amf” in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test “$dot_seen” = “no”; then \
make “$target-am” || exit 1; \
fi; test -z “$fail”
make: Fatal error: Command failed for target `all-recursive’
Current working directory /opt/src/libmcrypt-2.5.7
*** Error code 1
make: Fatal error: Command failed for target `all’
If I compile using gcc it makes successfully. What is the reasoning behind using cc instead of gcc?
Thanks,
Andy
5. Alasdair | January 31st, 2009 at 6:34 pm
Hi Andy,
Do you have Sun Studio 12 installed? Typing “which cc” should show something along the lines of:
# which cc
/opt/SUNWspro/bin/cc
The error message is a bit obscure and not terribly helpful, not having a “cc” is the first thing that springs to mind.
Generally an up to date and patched Sun Studio 12 produces “better” binaries than gcc (or so advocates tell me). However the main reason I do it is that we package up most of the things we compile for deployment to other servers, and I prefer to not have packages depend on libgcc. Quite often if you compile something with gcc it ends up linking against /usr/sfw/lib/libgcc_s.so.1
Generally I’ll try with Sun Studio first, then revert to gcc if it fails.
Murray - sorry for missing your comment. I’m not sure about your issue, if you’re still having problems, drop me an email: al at everycity dot co.uk.
Cheers!
6. Andy | February 6th, 2009 at 9:53 pm
Alasdair,
Thanks for your help so far. I downloaded and installed SunStudio 12. Now I can compile and install libmcrypt! Yay!
However, I am getting an error when doing the second part.
[root@shem : mcrypt]$ /opt/coolstack/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
NONE:0: /usr/sfw/bin/gm4: `__program__’ from frozen file not found in builtin table!
autom4te: /usr/sfw/bin/gm4 failed with exit status: 1
Any ideas?
I looked at your pre-compiled packages, but unfortunately they are for Solaris x86 not Sparc.
Thanks,
Andy
7. Paul | February 7th, 2009 at 9:18 pm
Hi,
When running the phpize command i got this error
# /opt/coolstack/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
8. Alasdair | February 8th, 2009 at 1:12 pm
Hi Andy,
I’m afraid not - looks Sparc specific. The Sun Forums have a Webstack section and may be able to help. Unfortunately we don’t have any Sparc boxes I can test things on.
Paul - You’ll need GNU Autoconf and Automake. They’re included on the Solaris 10 Companion DVD/CD, and have the names SFWaconf and SFWamake. If they’re already installed you just need to add them to your path, by doing:
export PATH=$PATH:/opt/sfw/bin
(Note the SFW Companion CD/DVD packages install to /opt/sfw NOT /usr/sfw (at least in Zones anyway)).
9. Mark | February 19th, 2009 at 5:32 pm
old post, but just to note, if your shell is zsh, you’ll encounter problems during the configure phase when it switches to configuring libltdl and you have set the compilers via CC and CXX env variables.
changing to bash for the configure and compile worked for me.
10. Gavin | March 30th, 2009 at 9:22 pm
I’ve successfully compiled the mcrypt modules for php - however when I view the php info via browser it does not display the support ciphers and modes for mcrypt.
Please advise
11. Chris | October 13th, 2009 at 7:18 pm
Hi, just wanted to say thanks! Your directions saved me a lot of time.
12. Martin Ramos | April 22nd, 2010 at 5:07 pm
It worked for me, I used a T2000 server SPARC, solaris 10 SPARC, in a Solaris 10 zone.
I just change:
libmcrypt-2.5.7 instead of libmcrypt-2.5.8
gcc instead of cc, because I had not cc installed.
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed