Latest blog entry

[Notice]: unserialize() [function.unserialize]: Error at offset

August 28, 2012    |   Posted by admin   |    Category: Linux Administration

The “function.unserialize” error occurs while installing Kayako or any other 3rd party application when the “magic_quotes_gpc” parameter is enabled.

By default the value of “magic_quotes_gpc” is On in the server side PHP configuration and thus you receive the following error message:

[Notice]: unserialize() [function.unserialize]: Error at offset 5 of
41 bytes (includes/functions.php:82)  UNSERIALIZE FAILED:
[Warning]: Cannot modify header information - headers already
sent by (Cookie/class.SWIFT_Cookie.php:157)

The “magic_quotes_gpc” can be disabled server wide ( in /etc/php.ini), however, if you want to keep it enabled server side, it can be disabled for the specific account as well either by using .htaccess (if server is non-SuPHP) i.e. placing the following line

php_value magic_quotes_gpc 0

OR by copying the server side php.ini file under the specific account or directory the application is downloaded

cp /etc/php.ini /home/user/public_html/

and turn off magic_quotes_gpc in new php.ini file (in case SuPHP is enabled).

Comments Off on [Notice]: unserialize() [function.unserialize]: Error at offset

How to install PHP 5.2 and PHP 5.3 together on cPanel server?

August 12, 2012    |   Posted by admin   |    Category: cPanel Management

Although PHP 5.2 is becoming outdated, still a lot of applications and custom scripts still works on PHP 5.2. However, as per cPanel PHP 5.2 is “End of Life” and may stop offering it soon. So here is the guide for people who want PHP 5.2 along side PHP 5.3 on a cPanel server and make use of both the PHP versions at the same time.

We are assuming the default PHP version installed on your sever is 5.3.x.

1. Download and untar PHP 5.2:

# mkdir /usr/local/buildphp52
# cd /usr/local/buildphp52
# wget http://museum.php.net/php5/php-5.2.9.tar.gz
# tar --strip-components=1 -zxvf php-5.2.*

2. Configure and install PHP

# ./configure --prefix=/usr/local/php52 --enable-cgi --enable-bcmath\
 --enable-calendar --with-mysql=/usr/bin -with-libdir=lib64\ --with-gd\
 --enable-mbstring   (you can add more modules per your wish)
 # make
 # make install

3. Now add the PHP 5.2 handlers to Apache

# pico  /usr/local/apache/conf/includes/pre_virtualhost_global.conf

add the following:

Action application/x-httpd-php52 /cgi-sys/php52
AddType application/x-httpd-php52 .php52

4. Use Apache distiller for the above changes to take affect and make cPanel skip .htaccess scan and remove the mime types:

# /usr/local/cpanel/bin/apache_conf_distiller --update
# touch /var/cpanel/easy_skip_update_php_mime_types

5. Now create a file under the cgi-sys directory of cPanel so it detects PHP 5.2

# pico /usr/local/cpanel/cgi-sys/php52

and add the following to it

#!/bin/sh
exec /usr/local/php52/bin/php-cgi

6. Set the proper ownership/permission

# chown root:wheel /usr/local/cpanel/cgi-sys/php52
# chmod +x /usr/local/cpanel/cgi-sys/php52

7. Now copy the php configuration from the build directory of PHP 5.2

# cp /usr/local/buildphp52/php.ini-production /usr/local/php52/lib/php.ini

8. Create a symlink for the PHP 5.2 executable to use from the command line:

# ln -s /usr/local/php52/bin/php-cgi /usr/local/bin/php52

9. Once done, restart Apache for changes to take affect

# service httpd restart

10. Now, PHP 5.3 will work by default and to make PHP 5.2 work for a specific account OR a folder, create a .htaccess file inside it and add the PHP 5.2 Handler

AddHandler application/x-httpd-php52 .php

That’s it. Create a phpinfo page inside the folder and browse it to see if PHP 5.2 is in effect for that folder.

Things to note is:  If you want to install OR compile a module with PHP 5.2, use appropriate php-config and phpize file, i.e.

phpize: /usr/local/php52/bin/phpize
php-config: ./configure --with-php-config=/usr/local/php52/bin/php-config
Comments Off on How to install PHP 5.2 and PHP 5.3 together on cPanel server?