Compiling PHP mcrypt extension
Note: These instructions are for RHEL4-based distributions.
You'll need the PHP 'devel' package, g++ and libtool to build mcrypt
apt-get install php-devel autoconf cpp gcc-c++ libtool
Grab it and install it
function installmcrypt() {
wget "http://easynews.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz"
if [ $? -ne 0 ]; then return 1; fi
tar xzf libmcrypt-2.5.7.tar.gz
if [ $? -ne 0 ]; then return 1; fi
cd libmcrypt-2.5.7
if [ $? -ne 0 ]; then return 1; fi
./configure --disable-posix-threads
if [ $? -ne 0 ]; then return 1; fi
replace "CFLAGS = -g -O2" "CFLAGS = -g -O2 --disable-posix-threads" -- Makefile
if [ $? -ne 0 ]; then return 1; fi
make && make install
if [ $? -ne 0 ]; then return 1; fi
}
installmcryptNow grab the PHP source and build the extension. You'll need the source tarball matching your distributions PHP version (4.3.7 for RHEL4).
function phpizemcrypt() {wget "http://www.php.net/get/php-4.3.9.tar.gz/from/www.php.net/mirror"if [ $? -ne 0 ]; thenwget "http://museum.php.net/php4/php-4.3.9.tar.gz"if [ $? -ne 0 ]; then return 1; fifitar xvzf php-4.3.9.tar.gzif [ $? -ne 0 ]; then return 1; ficd php-4.3.9/ext/mcryptif [ $? -ne 0 ]; then return 1; fiphpizeif [ $? -ne 0 ]; then return 1; fi./configureif [ $? -ne 0 ]; then return 1; fimake && make installif [ $? -ne 0 ]; then return 1; fi}phpizemcryptphpize failing? Try an older version of automake and then re-run phpize, configure, make, make install.
{
apt-get install automake-1.7
mv /usr/bin/aclocal /usr/bin/aclocal.old
ln -s /usr/bin/aclocal-1.7 /usr/bin/aclocal
}Finally, setup the extension in your php.ini or /etc/php.d if RHEL4-based, and restart Apache:
{
echo "extension=mcrypt.so" > /etc/php.d/mcrypt.ini
/etc/init.d/httpd restart
}Check to see that mcrypt shows up in a test phpinfo() page.
Other extensions can be built in a similar way (i.e. make sure you have the dependancies, grab the PHP tarball, and use phpize, configure, make, make install).
Testing php send mail capabilities
From:
http://www.webcheatsheet.com/php/send_email_text_html_attachment.phpEdit and save the following file in a externally accessible directory from your web server (usually /var/www/html or /var/www):
http://bliki.rimuhosting.com/space/knowledgebase/linux/webserver/apache/php/mailtest.phpThen if you saved it as test.php, go to
http://207.210.242.17/test.php and see if you got the e-mail. If you didn't check the mail logs (/var/log/maillog or /var/log/mail.log) to see what happened.
Enabling an upload directory for PHP scripts in Debian
The default php.ini file lacks the configuration directive for upload_tmp_dir, which is needed for file uploads. That is default on Debian for security purposes.
In order to use an upload directory, set the upload_tmp_dir parameter in php.ini to a directory that can be read and modified by the HTTP server user.