configure: error: Cannot find libmysqlclient under /usr

September 3, 2012    |   Posted by admin   |    Category: Linux Administration

Recently I was configuring PHP with Mysql manually and it was really annoying to see the “Cannot find libmysqlclient under /usr” error message. The configure line I used to install PHP was

./configure --with-mysql  --with-libdir=/usr/lib

and the error that I received was

checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

The error occurred because libmysqlclient wasn’t present in the /usr/lib directory. On further investigation, I noticed the libmysqlclient is installed in the /usr/lib64 directory because the server is a 64bit machine.

So the fix for the “mysql: Cannot find libmysqlclient under /usr” error message is to provide lib64 directory path in the configure line.

The configure line should read as follows:

./configure --with-mysql --with-libdir=lib64

That’s it.

Comments Off on configure: error: Cannot find libmysqlclient under /usr

[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?

How to install and configure APC cache on a cPanel server?

July 25, 2012    |   Posted by admin   |    Category: cPanel Management

For a plain Linux server, follow: How to install APC cache on a Linux server?

Installation of APC cache on a cPanel server is pretty easy. Follow the below steps to install APC cache on cPanel server:

1. SSH to the server and execute:

# yum install pcre-devel

2. Goto WHM –> PHP Configuration Editor –> Advanced Mode, change the  “extension_dir” value from

/usr/local/lib/php/extensions/no-debug-non-zts-20060613
to
/usr/lib/php/extensions/no-debug-non-zts-20060613

3. Install APC cache from WHM.

WHM --> Module Installers --> click Manage next to "PHP Pecl".
Search APC and install it.

4. Change PHP Handler to DSO. You can either do this from WHM OR via SSH:

WHM --> Service Configuration --> Apache Configuration -->
Configure PHP and SuExec --> PHP5 Handler
OR
# /usr/local/cpanel/bin/rebuild_phpconf 5 0 dso 1

Once done, make sure apc.so file is present in the /usr/lib/php/extensions/no-debug-non-zts-20060613 directory. Sometimes it is created in the original directory and you have to create a symlink.

# ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so \
 /usr/lib/php/extensions/no-debug-non-zts-20060613/apc.so

Restart the Apache webserver and to confirm if APC is activated, execute:

# php -i | grep apc
Comments Off on How to install and configure APC cache on a cPanel server?

ssh_exchange_identification: Connection closed by remote host

July 6, 2012    |   Posted by admin   |    Category: Linux Administration

Many a times when accessing a server via SSH you may end up with “ssh_exchange_identification: Connection closed by remote host” error message. For example:

# ssh root@testserver.com
ssh_exchange_identification: Connection closed by remote host

OR may be more descriptive error when you use the verbose mode (-v flag)

# ssh -v root@testserver.com
 OpenSSH_4.0p1, OpenSSL 0.9.7a Feb 19 2003
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: Applying options for *
 debug1: Connecting to testserver.com [1.1.1.1] port 22.
 debug1: Connection established.
 debug1: permanently_set_uid: 0/0
 debug1: identity file /root/.ssh/identity type -1
 debug1: identity file /root/.ssh/id_rsa type -1
 debug1: identity file /root/.ssh/id_dsa type 2

The ‘ssh_exchange_identification’ issue occurs for various reasons. So to fix the issue, check the following:

1) TCP wrappers i.e. whether ssh is restricted to certain IPs in /etc/hosts.allow and /etc/hosts.deny. If yes, make sure your local IP is added in the allowed list.

Edit the /etc/hosts.allow file and add the following at the top:

sshd : yourlocalip : allow

2) The /var/empty/sshd folder should be owned by user ‘root’. Sometimes if a new application is installed, it somehow changes the ownership of the /var/empty/sshd directory resulting in ‘ssh_exchange_identification’ error message.

# chown root.root /var/empty/sshd -R

3) If the permission of the private key files are incorrect i.e. if private key files are readable by all, it also results in “ssh_exchange_identification: Connection closed by remote host” error.

For example, if any of the private key file “ssh_host_key, ssh_host_rsa_key or ssh_host_dsa_key” in /etc/ssh directory have 644 permissions, they should be set to 600.

# cd /etc/ssh
# chmod 600 ssh_host_key ssh_host_rsa_key ssh_host_dsa_key
Comments Off on ssh_exchange_identification: Connection closed by remote host