Archive for the ‘Php’ Category

In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:

But more commonly, the error is often caused by the use of Short Open tags in PHP. To use short open tags, it must be enabled in PHP.INI.

short_open_tag = On

Some PHP compilation errors you may encounter while configuring PHP and their fixes:

checking for BZip2 support… yes
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution

yum install bzip2-devel


checking for cURL support… yes
checking if we should use cURL for url streams… no
checking for cURL in default path… not found
configure: error: Please reinstall the libcurl distribution –
easy.h should be in /include/curl/

yum install curl-devel


checking for curl_multi_strerror in -lcurl… yes
checking for QDBM support… no
checking for GDBM support… no
checking for NDBM support… no
configure: error: DBA: Could not find necessary header file(s).

yum install db4-devel


checking for fabsf… yes
checking for floorf… yes
configure: error: jpeglib.h not found.

checking for fabsf… yes
checking for floorf… yes
checking for jpeg_read_header in -ljpeg… yes
configure: error: png.h not found.

yum install libpng-devel


checking for png_write_image in -lpng… yes
If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.
Fix: Reconfigure your PHP with the following option.


checking for png_write_image in -lpng… yes
configure: error: libXpm.(a|so) not found.

yum install libXpm-devel


checking for bind_textdomain_codeset in -lc… yes
checking for GNU MP support… yes
configure: error: Unable to locate gmp.h

yum install gmp-devel


checking for utf8_mime2text signature… new
checking for U8T_DECOMPOSE…
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

yum install libc-client-devel


checking for LDAP support… yes, shared
checking for LDAP Cyrus SASL support… yes
configure: error: Cannot find ldap.h

yum install openldap-devel


checking for mysql_set_character_set in -lmysqlclient… yes
checking for mysql_stmt_next_result in -lmysqlclient… no
checking for Oracle Database OCI8 support… no
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

yum install unixODBC-devel


checking for PostgreSQL support for PDO… yes, shared
checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

yum install postgresql-devel


checking for sqlite 3 support for PDO… yes, shared
checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext
checking for sqlite3 files in default path… not found
configure: error: Please reinstall the sqlite3 distribution

yum install sqlite-devel


checking for utsname.domainname… yes
checking for PSPELL support… yes
configure: error: Cannot find pspell

yum install aspell-devel


checking whether to enable UCD SNMP hack… yes
checking for default_store.h… no

checking for kstat_read in -lkstat… no
checking for snmp_parse_oid in -lsnmp… no
checking for init_snmp in -lsnmp… no
configure: error: SNMP sanity check failed. Please check config.log for more information.

yum install net-snmp-devel


checking whether to enable XMLWriter support… yes, shared
checking for xml2-config path… (cached) /usr/bin/xml2-config
checking whether libxml build works… (cached) yes
checking for XSL support… yes, shared
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install libxslt-devel


configure: error: xml2-config not found. Please check your libxml2 installation.

yum install libxml2-devel


checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

yum install pcre-devel


libtool: link: cannot find the library `/usr/lib/’ or unhandled argument `/usr/lib/’
make: *** [sapi/cgi/php-cgi] Error 1

cd /usr/src/
tar -zvxf libidn-1.26.tar.gz
cd libidn-1.26
make install
ln -s /usr/local/lib/ /usr/lib/


libtool: link: `/usr/lib/’ is not a valid libtool archive
make: *** [ext/xsl/] Error 1

cd /usr/src/
tar -zvxf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
./configure –prefix=/usr
make install

configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.


yum install t1lib-devel.x86_64
configure: error: mcrypt.h not found. Please reinstall libmcrypt.


yum install libmcrypt-devel.x86_64
configure: error: Cannot find libtidy

yum install libtidy libtidy-devel

I have faced an error while checking php version

Error while loading shared libraries: /usr/lib/ requires glibc 2.5 or later dynamic linker


cd /usr/lib/

ls -la libst*;

#then remove symbolic link

#then recreate symbolic link for OLD file because not working

ln -s /usr/lib/

#check what you done
ls -la libst*;

How to install Custom PHP Version for suphp handler domains.

# cd /usr/src
# wget
# tar -zvxf php-5.4.17.tar.gz
# cd php-5.4.17

To check the current PHP configuration option

# php -i | grep configure

Here I am using prefix as /usr/local/php-5.4.17

[ #./configure –prefix=/usr/local/php-5.4.17 –enable-cli –enable-cgi –with-curl –as per your requirements.

#make install

Check the PHP Version

-bash-4.1# /usr/local/php-5.4.17/bin/php -v
PHP 5.4.17 (cli) (built: Jul 19 2013 00:45:34)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd.

Copy the main php.ini on the Custom php location, here it is /usr/local/php-5.4.17/lib

Check the current configuration file for Custom php.ini

-bash-4.1# /usr/local/php-5.4.17/bin/php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php-5.4.17/lib
Loaded Configuration File => /usr/local/php-5.4.17/lib/php.ini

Add the required PHP modules on extension directory. Here I have downloaded the ionCube and copy the .so module on ***20100525 directory


# vim /opt/suphp/etc/suphp.conf


# /usr/local/apache/conf/includes/pre_main_2.conf

Allow from All

### check the domain document root and set info page.
suPHP_AddHandler application/x-httpd-php5.4
AddType application/x-httpd-php5.4 .php

Also add the handler in the domain .htacess file.

/etc/rc.d/init.d/httpd configtest
/etc/rc.d/init.d/httpd restart


WordPress and many other open source application developers asks users to protect PHP apps using Suhosin patch to get protection from the full exploit. Suhosin is an advanced protection system for PHP installations. It was designed to protect your servers from various attacks. How do I install Suhosin under RHEL / CentOS / Fedora Linux?
A. Suhosin was designed to protect your servers against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself including wordpress and many other open source php based apps.

Install Suhosin as extension

Download latest version of Suhosin, enter:
# cd /opt
# wget
Make sure you have php-devel installed:
# yum install php-devel
Compile Suhosin under PHP 5 and RHEL / CentOS Linux
Type the following commands:
# cd suhosin-0.9.27
# phpize
# make
# make install
Configure Suhosin
Type the following command to create Suhosin configuration file:
# echo ‘’ > /etc/php.d/suhosin.ini

Restart web server
# service httpd restart
If you are using lighttpd, enter:
# service lighttpd restart

Verify Suhosin installation
$ php -v
Sample output:
PHP 5.1.6 (cli) (built: Jun 12 2008 05:02:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

You can find more information by running phpinfo():

Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

Make the Sources Folder
mkdir ~/memcache

Compile and Install LibEvent

cd ~/memcache
tar xvfz libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
make install

Compile and Install Memcache

cd ~/memcache
tar xvfz memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure –with-lib-event=/usr/local/
make install

Starting Memcache

If you get the following error then you may beed to register libevent:
error while loading shared libraries: cannot open shared object file: No such file or directory

Register LibEvent

vi /etc/
Open above file and put the line /usr/local/lib/ and save the file and fire below command.

Installing PHP Memcache

cd ~/memcache
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
make install

Add extension on php.ini

vi /usr/local/lib/php.ini

Then restart the Apache service.
service httpd restart

Reference :
Reference :

The Zend Guard Loader runs PHP scripts that are encoded with Zend Guard. The Zend Guard Loader is a PHP extension that runs outputs created by Zend Guard, which provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line.

The Guard Loader extension must be installed on each Web server that runs files that were encoded with, or use, Zend Guard licenses.

You can also use the Zend Optimizer that also includes the Guard Loader extension for code written in PHP 5.2. The Zend Optimizer is available as a free download from PHP Web Application Server – PHP Development tools – PHP Training –

The Zend Guard Loader translates encoded files to a format that can be parsed by the Zend Engine. This runtime process uses the Zend engine as a trigger to start the Zend Guard Loader component. Zend Guard is a separate product available from Zend that provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line. To view the API, click Zend Guard Loader.

To install it you need to follow the below mentioned steps:

# wget
# tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ /usr/local/lib/php

Now after that open php.ini file and put a

restart apache

php -v to check it will show as

# php -v
PHP 5.3.15 (cgi-fcgi) (built: Sep 17 2012 04:07:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies


PHP Fatal Error: Out Of Memory

PHP Fatal error: Out of memory (allocated 45236595) (tried to allocate 74521 bytes) in /home/xxxxx/public_html/xyz/admin.php(154) on line 40

Solution is to increase the memory allocated for PHP.

1. Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini

Open the php.ini file in a text editor and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.

2. In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after
ini_set(’memory_limit’, ‘12M’);

3. You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M

4. Or else, Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define(‘WP_MEMORY_LIMIT’, ’32M’);

SuExec server permission issue?

After enabling SuExec on server most users getting “500 Internal Server Error” at that time refer following steps.

1st) Correct cPanel users files/directories ownership.


for i in `cat /etc/trueuserdomains | awk ‘{print $2}’`
chown $i.$i /home/$i -R;
chown $i.mail /home/$i/etc -R;
chown $i.nobody /home/$i/public_html;


2nd) Correct permission for files and directories for cPanel users from shell but make sure that you logged in as root user and running following command in /home partition.


find . -type d -perm 777 -exec chmod 755 {} \;

find . -type f -perm 644 -exec chmod 755 {} \;

Cannot load mysql extension. Please check your PHP configuration

How do I fix this problem under CentOS / RHEL / Fedora Linux Apache web server?

You need to install php-mysql which is a module for PHP applications that use MySQL databases. And you may also need to install the following:

php-mysql : Module for PHP applications that use MySQL databases
php-gd : A module for PHP applications for using the gd graphics library
php-mbstring : A module for PHP applications which need multi-byte string handling
php-mcrypt : Standard PHP module provides mcrypt library support

Type the following command to fix your issue:
# yum -y install php-mysql
# service httpd restart

No need to edit /etc/php.ini as php-mysql package comes pre configured with /etc/php.d/mysql.ini file:
# cat /etc/php.d/mysql.ini

Sample outputs:
; Enable mysql extension module
Optional Modules

To install other modules type:
# yum -y install php-mbstring php-mcrypt php-gd
# service httpd restart