Custom php.ini for PHP CGI in cPanel.

February 26, 2010 on 3:36 am | In Cpanel, PHP | No Comments

Hi guys,

When PHP is compiled as CGI, you won’t be able to provide custom php flags in .htaccess or just simply add a php.ini if your home directory.

To enable a custom php.ini for your domain running PHP as cgi, perform the following steps.

Please note that I am considering that the server has PHP4 and PHP5 where PHP4 is default (dso)-not relevant and PHP5 (cgi)

My username is “presoon” so my home directory will be “/home/presoon” (replace with yours)

create a custom cgi script in your cgi-bin directory.

vi /home/presoon/public_html/cgi-bin/php.cgi

add the following contents.

#!/bin/sh
exec /usr/local/cpanel/cgi-sys/php5 -c /home/presoon/public_html/

You should have the custom php.ini at “/home/presoon/public_html/”

chown presoon.presoon /home/presoon/public_html/cgi-bin/php.cgi
chmod 755 /home/presoon/public_html/cgi-bin/php.cgi

Now to the .htaccess file at “/home/presoon/public_html/”
Add the following

AddHandler application/x-httpd-php5 .php
Action application/x-httpd-php5 /cgi-bin/php.cgi

Please note that AddHandler given above is to change default php to PHP5. If you have only PHP5 which is compiled as CGI, you can remove the directive AddHandler from .htaccess.

Now the values given in your php.ini at /home/presoon/public_html/ should reflect you info page. :)

Suhosin : Exclude a domain from disabled functions

July 8, 2009 on 9:09 am | In PHP | 1 Comment

when you use use “suhosin.executor.func.blacklist”, in php.ini it will disable those functions to entire domains in the server.

However, you can exclude domains from that restriction by using the appropriate entry in the apache configuration.

If in php.ini you have added suhosin.executor.func.blacklist = “exec,passthru,shell_exec” and all the functions that you want to disable globally.

Find the corresponding domain’s Virtual Host entry for which you want to exclude from /usr/local/apache/conf/httpd.conf suhosin.executor.func.blacklist again but without the function that you need to enable. And so you will enable that function only for one domain.

<VirtualHost 78.45.23.1:80>
………..
………..
<IfModule mod_php4.c>
php_admin_value open_basedir “/usr/lib/php”
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir “/usr/lib/php”
php_admin_value suhosin.executor.func.blacklist = “passthru,shell_exec”
</IfModule>
…….
……
</VirtualHost>

In this example exec has been enabled for the VirtualHost.

Thats all

Install PHP-MemCache Module On CentOS 5.0 + RHEL

January 17, 2009 on 3:27 pm | In Apache, Installation, PHP | No Comments

Download

wget http://pecl.php.net/get/memcache-2.1.2.tgz
tar -zxf memcache-2.1.2.tgz
cd memcache-2.1.2

phpize &&
./configure –enable-memcache
make
make install

This should create memcache.so in your extenstion directory (/usr/lib/php/modules)

If it is not done copy the file memcache.so to the default module directory.
locate your php.ini file

php -i| grep php.ini

add the line

———————
extension=memcache.so
———————

Restart Apache

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

check the module is working
php -i| grep memcache.

should show something like

=============
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user memcache
OLDPWD => /usr/local/src/ezsmsupport/memcache-2.1.2
=============

Also, you can find it in your phpinfo page.
Thats all.

PhpMyAdmin Installation

January 8, 2009 on 5:48 pm | In Mysql, PHP | No Comments

PhpMyAdmin Installation for a domain is so easy.

Enter into your webdirectory (public_html)

Download the source into it.

From shell

wget http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.1-english.tar.gz

or download the source from http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.1-english.tar.gz and upload it via FTP to your public_html

extract the contents

tar -zxf phpMyAdmin-3.1.1-english.tar.gz

Alternatively you may use the filemanger extract option for the purpose.

you can now access your phpmyadmin using the link

www.yourdomain.com/phpMyAdmin-3.1.1-english/

Before that you need to configure that.

You need to have

1 database

2 database user

3 database user password.

Now navigate to the directory libraries under /phpMyAdmin-3.1.1-english/ you will have a file named config.default.php.

You need to edit this file

===================
$cfg['Servers'][$i]['host'] = ‘1002-2.lowesthosting.com’; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ‘4455′; // MySQL port – leave blank for default port
$cfg['Servers'][$i]['socket'] = ‘/tmp/mysqlt.sock’; // Path to the socket – leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = ’socket’; // How to connect to MySQL server (‘tcp’ or ’socket’)
$cfg['Servers'][$i]['extension'] = ‘mysql’; // The php MySQL extension to use (‘mysql’ or ‘mysqli’)
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser'] = ‘username’; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ‘password’; // access to the “mysql/user”
// and “mysql/db” tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = ‘http’; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = ‘username’; // MySQL user
$cfg['Servers'][$i]['password'] = ‘password’; // MySQL password (only needed
// with ‘config’ auth_type)
$cfg['Servers'][$i]['only_db'] = ‘trial’; // If set to a db-name, only
// this db is displayed in left frame
====================

Update the above with database name, username, password, control user and password which can be the same as db user and password.

Now try accessing the link www.yourdomain.com/phpMyAdmin-3.1.1-english/
enter the login credentials.

Thats all.

Ioncube Installation

October 19, 2008 on 7:59 pm | In Cpanel, Installation, PHP | No Comments

Ioncube is easy to install without recompiling PHP. Specifically in cpanel servers you can install Ioncube without recompiling PHP.

These steps can be used to install in any Linux servers..

Check the architecture.

uname -i

cat /etc/redhat-release

Download the source from the link

http://downloads2.ioncube.com/loader_downloads/

For i316 architecture linux server select

ioncube_loaders_lin_x86.tar.gz

2. Installation

cd /usr/local/src/

wget http://downloads2.ioncube.com/loader_downloads/<source>.tar.gz

tar zxvff <source>.tar.gz

mv ioncube /usr/local

Locate you php.ini file using the command

php -i | grep php.ini

open up the php.ini file using any editors, find the “zend_extension” and add the line

zend_extension=/usr/local/ioncube/ioncube_loader_lin_x.x.so

Don’t forget to replace x.x with the php verision. For example you have php version 5.2.6, replace the x.x with 5.2.

Restart Apache

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

Test it

php -v

It should show Ioncube.

Suexe issue + PHP cgi… individual php.ini file wont reflect….Cpanel

October 10, 2008 on 11:17 pm | In Cpanel, PHP | 1 Comment

The php.ini files in your home directory won’t reflect the changes.

Perform the following actions to get it resolved.

1. Moving php5 binary:

mv /usr/local/cpanel/cgi-sys/php5 /usr/local/cpanel/cgi-sys/php5.bin

2. Then creating wrapper file in the /usr/local/cpanel/cgi-sys/php5 with the following content:

#!/bin/bash

# This will fake the name & path and hide the /usr/local/cpanel/cgi-sys/php5 path!
export SCRIPT_NAME=$REQUEST_URI
export SCRIPT_FILENAME=$PATH_TRANSLATED
export PWD=$DOCUMENT_ROOT

if [ -f "$DOCUMENT_ROOT/php.ini" ]; then
exec /usr/local/cpanel/cgi-sys/php5.bin -c $DOCUMENT_ROOT
else
exec /usr/local/cpanel/cgi-sys/php5.bin
fi

3. Save the file and change the permissons:

chown root:wheel /usr/local/cpanel/cgi-sys/php5*;
chmod 755 /usr/local/cpanel/cgi-sys/php5*;

Thanks to Cpanel forums…..

Install php 5.2 in Ubuntu

May 21, 2008 on 3:36 am | In PHP | No Comments

Installing PHP 5.2

Adding the Dotdeb repository

We’re going to add the Dotdeb repository, which will provide the latest versions of PHP for Debian. We need to modify the sources.list file by running the following command

vi /etc/apt/sources.list

Once you have sources.list file open, add the two following lines

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

Now let’s update the packet database to add those of Dotdeb. The version of Dotdeb packets being always superior to those of Debian, the Dotdeb versions will be automatically selected during the installation of PHP

Installing PHP 5

After having added the Dotdeb repository, we can move on to installing PHP:

apt-get install php5-mysql
apache2ctl restart

Test PHP by checking the phpinfo page

jmorecfg.h

April 26, 2008 on 3:06 pm | In Installation, PHP | No Comments

If this header file is not found when you give make for gd installation download it

===================
wget http://www.ece.cmu.edu/~ece796/project99/7/final/code/jmorecfg.h

mv jmorecfg.h /usr/lib/
===================

===================
updatedb
===================
or
===================
ldconfig
===================

jpeglib.h

April 26, 2008 on 3:04 pm | In Installation, PHP | No Comments

If this header file is not found when you give make for gd installation download it

===================
wget http://dev.w3.org/cvsweb/Amaya/libjpeg/jpeglib.h?rev=1.2

mv jpeglib.h?rev=1.2 /usr/lib/
===================

===================
updatedb
===================
or
===================
ldconfig
===================

configure: error: freetype.h not found

April 26, 2008 on 2:58 pm | In Installation, PHP | 1 Comment

Download the version you need from

http://download.savannah.gnu.org/releases/freetype/

Example for freetype-2.1.10

cd /usr/local/src
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.1.10.tar.gz
tar -zxf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure
make
make install

Next Page »