Error while loading shared libraries: libmm.so.14

Saturday, December 19th, 2009 | Linux | No Comments

As the title say, that’s an error message which I received when trying to compile a php version with mm as a ./configure option.

fixing it is as easy as checking debug.log in your php source directory, searching where the php is looking for libraries (mine was in /usr/local/lib64) and than just creating a symlink for libmm.so.14 to /usr/local/lib64

Don’t have libmm at all? Go to http://www.ossp.org/pkg/lib/mm/ and install the library.

Update: apparently in php.ini you need to uncomment the session save path directive as otherwise the default path is / which triggers a permission error. Because of this the mm session handler does not get registered with php

An apache php fastcgid suexec cpanel story

Sunday, December 13th, 2009 | Linux | No Comments

I wanted to get fastcgid running on cpanel/whm, so I went to easyApache and selected to compile apche with fastcgid support and php with fastcgi support, but guess what – it wasn’t working! they just ignored the settings and php was compiled without fastcgi in it.

So back to the beggining, dreaming of my lost time figuring out what the heck was wrong with whm/cpanel/easyapache I turned to plan B.

I recompiled apache still with easyapache from whm but without php. Further more I also choosed MPM worker module to improve the way static content is served. (!!! mpm worker is not compatible with PHP as an apache module)

Next step I compiled php from source – see my other article regarding compiling php from source and checking what I used as ./configure command.

Note: if you don’t have mod_fcgid module installed do this command in the directory you extracted the mod_fcgid archive that you got from apache website:
./configure.apxs
make
make install

I went to httpd.cnf -> on my system was on /usr/local/apache/conf and added the following lines:


AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /home/user/php-wrapper .php
Order allow,deny
Allow from all

Now I create the wrapper that will execute the php:

cd /home/user
sudo vi php-wrapper

add this inside the file:

#!/bin/sh
exec /usr/local/php-5.3.2-fcgi/bin/php-cgi

then, some security aspects (it’s required by suexec and it’s nice organizing things a little):

sudo chown user.nobody php-wrapper
sudo chmod 550 php-wrapper
cd ..
sudo chown -R user.nobody user/public_html
sudo chmod -R 0750 user/public_html

!Make sure you change the path of the fcgid wrapper to fit your php directory you have just compiled.

make sure suexec is enabled (it’s installed by default in whm, and you can enabled from php&sexec configuration section)
Restart apache and that’s it, or should I say… good luck :)

Note: you need to learn how to optimize fcgid config variables and because mpm worker was also installed, it’s corresponding configuration variables as well. But till you do, the default will be just fine.

Please study the instructions and make sure you understand them before breaking a live server

Install php from source – custom path

Sunday, December 13th, 2009 | Linux | No Comments

Hey guys,

Recently I wanted to give php 5.3.1 a go but without interferring with my current setup, so I choosed to run it as fcgi.
In order to do that I wanted to compile php from source, enabling the modules I needed (gd with jpg support), bmath, pdo, pdo_mysql (for magento) and so on

here we go:
1. go to php site and download your version
2. upload to your server and unarchive it somewhere :)
3. go using putty or something similar to where are the files extracted, enter the source directory
4. I used this command, change it per your needs:
./configure –enable-bcmath –enable-calendar –enable-fastcgi –disable-cli –enable-ftp –enable-gd-native-ttf –enable-libxml –enable-magic-quotes –enable-mbstring –enable-soap –enable-sockets –prefix=/usr/local/php-5.2.13-fcgi –with-curl=/opt/curlssl/ –with-jpeg-dir=/usr/lib –with-jpeg –with-png-dir=/usr/lib –with-libdir=lib64 –with-gd –with-mm –with-mcrypt=/opt/libmcrypt/ –with-mysql=/usr –with-mysql-sock=/var/lib/mysql/mysql.sock –with-mysqli=/usr/bin/mysql_config –with-openssl=/usr –with-openssl-dir=/usr –with-zlib –with-zlib-dir=/usr –enable-pdo –with-pdo-sqlite –with-sqlite –with-pdo-mysql=/usr –with-pdo-sqlite –enable-zend-multibyte –with-freetype-dir=/usr –with-gettext –with-ttf –enable-force-cgi-redirect –enable-sysvsem –enable-sysvshm
5. make
6. make install

make sure you rename and copy the development php.ini to the lib/php.ini

Install pdo_mysql – no recompiling php

Sunday, December 13th, 2009 | Linux | 1 Comment

I googled till 4 AM to check how can I enable/install pdo_mysql for magento without the need to reinstall php – as all posts pointed I should do
finally I get it working

From here I started:
1. I already had pdo
2. I hadn’t pdo_mysq;

so back to work (as root):
1. Download PDO_MYSQL from http://pecl.php.net/package/PDO_MYSQL
2. upload it to your server
3. run export PHP_PREFIX="/usr/local/php/"
4. run $PHP_PREFIX/bin/phpize
4. run ./configure '--with-pdo-mysql=shared,/usr' !! /usr was where my mysql was installed (not where the data of mysql are!)
5. make
6. make install
7. in your php.ini
8. add
extension_dir = "/usr/local/php/extensions/no-debug-non-zts-20060613"
extension=pdo_mysql.so

9. restart apache

Install eaccelerator from scratch – Centos

Sunday, December 13th, 2009 | Linux | No Comments

1. download the source code and upload it to your server
2. execute
export PHP_PREFIX="/usr/local/php/"
where /usr/local/php/ is my path to where php is installed
3. $PHP_PREFIX/bin/phpize
4. ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
5. make
6. make install
7. now go to php.ini and include this code:
zend_extension="/usr/local/php5.2.12-fcgi/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eacc-php5.2.12-fcgi"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter="*.php"
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="7200"
eaccelerator.shm_prune_period="7200"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="8"
eaccelerator.keys = "shm"
eaccelerator.sessions = "shm"
eaccelerator.content = "shm"

make sure you change the extension path above to fit your php extension directory
8. restart apache

Overlength date field error in prestashop

Saturday, December 12th, 2009 | Web development | No Comments

Recently I got this error when trying to send emails in prestashop.
An email was bouncing back and it contained the following message:
This message has been rejected because it has
an overlength date field which can be used
to subvert Microsoft mail programs

After a lot of headaches and a cofee :) I manage to detect what was wrong:
Presta uses in the email class a variable $templateVars
this was like:

$templateVars = array(
‘{date_facturare}’ =>
‘Nume Firma: ‘.$invoice->company.’<br>’.
‘Cod fiscal: ‘.$invoice->tax_code.’<br>’.
‘Registrul Comertului: ‘.$invoice->reg_data.’<br>’.
‘IBAN: ‘.$customer->iban.’<br>’,
‘CNP: ‘.$invoice->cnp.’<br>’,
‘{firstname}’ => $customer->firstname,
‘{lastname}’ => $customer->lastname, …

However the problem was because of a , instead of .
'IBAN: '.$customer->iban.'<br>',
should have been:
'IBAN: '.$customer->iban.'<br>'.

Because of the wrong “,”, $templateVars[0] was taking a long value and apparently Swift Mailer was appending it to the header date of the email hence the error with the overlength date field.

Tags: ,

Restart apache when server load is too big

Tuesday, December 8th, 2009 | Linux | 1 Comment

Some times one of the hosting servers is going crazy with load of over 200 crashing the server eventually.
The load is because of a strange php script that I can not find it for now. Anyway if you want to restart apache when your server load is too big and to receive an email when this happens here you go:

#!/bin/bash
MAXLOAD="5"
L05="$(uptime | gawk -F"load average: " '{ print $2 }' | gawk -F", " '{ print $1 }')"
if [ $(echo "$L05 > $MAXLOAD"|bc) -eq 1 ]
then
unlink /tmp/message.txt
MESSAGE="/tmp/message.txt"
echo "restarting apache" >> $MESSAGE
/bin/mail -s "big load $L05" "myemail" < $MESSAGE
/etc/init.d/httpd restart
fi

feel free to add it to your cron job

Cakephp – JsController could not be found

Sunday, August 16th, 2009 | Web development | No Comments

Recently I wanted to test the ajax capabilities from cakePHP and after setting up the links to prototype.js and scriptaculous.js just as shown on cakePHP website, I’ve noticed the ajax is not working.

In the javascript error console I noticed the error:
JsController could not be found

The problem was that I thought cake will include the above js files automatically from it’s core libraries. Of course it doesn’t so to solve the problem just download prototype.js and scriptaculous.js and place them in the js directory inside webroot

That’s it!

GoDaddy 500 Internal Server Error – Windows Shared hosting

Thursday, August 13th, 2009 | Web development | No Comments

500 - Internal server error

Today I needed to move some sites to a different server.  A wordpress and an old oscommerce. The server was a windows server from godaddy – the hosting was a shared one

After setting up the database and the files I run into this error:

500 Internal Server Error
› Continue reading

Godaddy custom php.ini problems and solutions

Wednesday, August 12th, 2009 | Web development | 1 Comment

Godaddy can be a killer of time for a programmer. It can take ages to figure out some things that are just now standard to webhosting.

Recently I took care of a client that had a windows hosting package and needed a script setup that required custom modifications to php.ini.

I’ve placed php5.ini to root web directory (for godaddy if you have php5 installed, php5.ini is required otherwise php.ini) the custom settings were in effect and guess what? mysql wasn’t working anymore:

Fatal error: Call to undefined function mysql_connect() in xxxxxxxx

Solution is to set up a complete php.ini file (you can take it from your computer) from which settings like upload_tmp_dir should be set up from the original php.ini

Of course how the heck you can read the original php.ini? You don’t need to, just create a a test.php and place  phpinfo(); there and you should be able to read all the variables that required path alterations to fit the server.

Questions? Please let me know