Category Archives: Howto

fix gpac problem: /usr/bin/ld: cannot find -lgpac_static

Some time you might facing some problem during installing ffmpeg:

gpac problem /usr/bin/ld: cannot find -lgpac_static
Here is the solution:
1st:

yum install mesa-libGL-devel
yum install mesa-libGLU-devel
yum install libXi-devel
yum install libXmu-devel
yum install freeglut-devel

then:

wget http://downloads.sourceforge.net/gpac/gpac-0.4.5.tar.gz
wget http://downloads.sourceforge.net/gpac/gpac_extra_libs-0.4.5.tar.gz
tar zxvf gpac-0.4.5.tar.gz
tar zxvf gpac_extra_libs-0.4.5.tar.gz
cd  gpac
cp -r ../gpac_extra_libs/* extra_lib/
chmod +x configure
./configure
make lib
make apps
make install-lib
make install
cp bin/gcc/libgpac.so /usr/lib

Apache ServerRoot Directories Permissions

 

Permissions on Apache ServerRoot Directories

If you allow non-root users to modify any files that root either executes or writes on then you open your system to root compromises.

For example, someone could replace the httpd binary so that the next time you start it, it will execute some arbitrary code. If the logs directory is writeable (by a non-root user), someone could replace a log file with a symlink to some other system file, and then root might overwrite that file with arbitrary data. If the log files themselves are writeable (by a non-root user), then someone may be able to overwrite the log itself with bogus data.

If you choose to place ServerRoot in /usr/local/apache then it is suggested that you create that directory as root, with commands like these:

mkdir /usr/local/apache
cd /usr/local/apache
mkdir bin conf logs
chown 0 . bin conf logs
chgrp 0 . bin conf logs
chmod 755 . bin conf logs

It is assumed that /, /usr, and /usr/local are only modifiable by root. When you install the httpd executable, you should ensure that it is similarly protected

cp httpd /usr/local/apache/bin
chown 0 /usr/local/apache/bin/httpd
chgrp 0 /usr/local/apache/bin/httpd
chmod 511 /usr/local/apache/bin/httpd

faad problem: ERROR: libfaad not found

When you compile ffmpeg sometime you might found:

./configure --prefix=/usr/local --enable-gpl --enable-shared  --enable-mp3lame --enable-amr_nb --enable-amr_wb --enable-amr_if2  --enable-a52 --enable-a52bin --enable-faadbin --enable-dts --enable-pp  --enable-faad --enable-pthreads --disable-ffserver --disable-ffplay
ERROR: libfaad not found
If you think configure made a mistake, make sure you are using the  latest
version from SVN.  If the latest version fails, report the problem to  the
devel@mplayerhq.hu[/email]  mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.err" produced by configure as this will  help
solving the problem.

Here is the solution:

tar zxvf faad2-2.5.tar.gz
cd faad2
echo > plugins/Makefile.am
echo > plugins/xmms/src/Makefile.am
sed -i '/E_B/d' configure.in
autoreconf -vif
./configure --prefix=/usr
make
make install

PHP Page Rank Checker Script 2011 (PR Checker)

PR Checker(100% tested Working)

The Google PageRank is a  ranking architecture  implemented by Google to give  domain a rank. In other hand, the more well known of your web site, then you will get more higher page rank. Google has offered this services awhile ago, there is multiple site that has page rank checker services on internet. I found a working version of google page rank checker script to replace the one that i posted previously here. The old version is not functioning anymore, here is the latest update:

< ?php

function GetPageRank($q,$host='toolbarqueries.google.com',$context=NULL) {
	$seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
	$result = 0x01020345;
	$len = strlen($q);
	for ($i=0; $i<$len; $i++) {
		$result ^= ord($seed{$i%strlen($seed)}) ^ ord($q{$i});
		$result = (($result >> 23) & 0x1ff) | $result < < 9;
	}
	$ch=sprintf('8%x', $result);
	$url='http://%s/tbr?client=navclient-auto&ch=%s&features=Rank&q=info:%s';
	$url=sprintf($url,$host,$ch,$q);
	@$pr=file_get_contents($url,false,$context);
	return $pr?substr(strrchr($pr, ':'), 1):false;
}

if (isset($_GET['q'])) { echo "Page Rank: ".GetPageRank($_GET['q']); }
?>

Another Example with Image:

< ?php
if(isset($_GET['q']))
{
function GetPageRank($q,$host='toolbarqueries.google.com',$context=NULL) {
	$seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
	$result = 0x01020345;
	$len = strlen($q);
	for ($i=0; $i<$len; $i++) {
		$result ^= ord($seed{$i%strlen($seed)}) ^ ord($q{$i});
		$result = (($result >> 23) & 0x1ff) | $result < < 9;
	}
	$ch=sprintf('8%x', $result);
	$url='http://%s/tbr?client=navclient-auto&ch=%s&features=Rank&q=info:%s';
	$url=sprintf($url,$host,$ch,$q);
	@$pr=file_get_contents($url,false,$context);
	return $pr?substr(strrchr($pr, ':'), 1):false;
}




$pr = GetPageRank($_GET['q']);

header("Content-type: image/gif");
switch($pr)
{
case 0:
header("Content-length: 272");
echo base64_decode(
'R0lGODlhRgAUAKIAAKSkpL+/v9zc3JSUlPT09AAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPVaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkAAgHAsCha7YwyGDY6+ONk7bGACvIDlS7sjSsnD6/56+lqggc'.
'AgZ+gDlHYHZiGk9AaItANzoLbVsABwJwU2RLelKOUHiHVJAKkg'.
'aUloQ7IWM/JXwGpKaXJXqsraKvB5OVsrW9IreCgX+8RcUTaVZZ'.
'AVhbqDa+vamuwhaDznvQ0chqAG9cK4/ZrNK3FF17xulc2Mbn4u'.
'KpP+rz9BMJADs='.
'');
break;
case 1:
    header("Content-length: 262");
    echo base64_decode(
'R0lGODlhRgAUAKIAAACZM6Wlpdzc3L29vZSUlAAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPLaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'h0CA4Bh67ZwiCDX66PF07aHgNLVrUbS7/K6bNb7lqqCgJmnTt6'.
'5WAaT0BmhEA3OgsBBwNXfAtbhyxSk0h2h1B0gFSJeQQGjlorIW'.
'E/JXgMoWwml6YnnalYojuutSKwC6p9tEW9E2cPupCjBgDGALY/'.
'vLgKwka8x8jJJsu+kTfR09TARde+3w/cONfa07TK4OnqEgkAOw'.
'=='.
'');
break;
case 2:
    header("Content-length: 271");
    echo base64_decode(
'R0lGODlhRgAUAKIAAN3d3b6+vqmpqZeXlwCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPUaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkCACWgEPXbGGQQXDXxxMnbY2BBXvQ5o4xLxAqny+95npVETgA'.
'DAJ+KjtOU2BkQGVhhol7CgMDgIJvhF9SLHKXT5h4jFQ6D1gCgy'.
'ViPyWOj1hulCZ1pyegDKsPXLC3Hqm0tSuyRb+1Fo59GH+twgTJ'.
'ygS4qGizGcYLtjfLys2xwr4U1AbWydghOzfbE93A6FvawNTh2O'.
'M/6fLzEwkAOw=='.
'');
break;
case 3:
    header("Content-length: 274");
    echo base64_decode(
'R0lGODlhRgAUAKIAAKqqqr+/v5iYmObm5gCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPXaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkAAaHgcCha7YwyGDY6+ONk7aGwILV5Y6xLxAqny+/53pVcQ0Y'.
'sAAqO05TYWVAZmKFiHsNWFxwd3VSUoh0aHZUbhUHgYIlYz8ljQ'.
'sBWFtvOzSHoiKbDQBZn620Ho0BB36xA7OvRb9cFrcWuJ29BgTJ'.
'ysvJtRyqpMW5kNDM1gTOG9C+BgIAqMfXzNka28BdwsDqwTfcEu'.
'jk5Ko/6/X2EwkAOw=='.
'');
break;
case 4:
    header("Content-length: 265");
    echo base64_decode(
'R0lGODlhRgAUAKIAAJmZmdvb26+vr/f39wCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPOaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'h8BAIOXbOFQQa9Wx8PnLRBApbsMcYFQtvuJZcMrzIEH9XOOfWK'.
'gWNffYB2CgADaDo5a3JwUlKAb2VxVIoLAQM7ajshYD8lhXgCmn'.
'omcJ8nljtXFgEAi5yoshyFG6MLWmlFuxJmELqwHwTDxMXGBLMY'.
'nIU5qkTCx9HDyTZpzhO5N9LS1NbWvNm84g++Rdnd1LEw4+ztEw'.
'kAOw=='.
'');
break;
case 5:
    header("Content-length: 271");
    echo base64_decode(
'R0lGODlhRgAUAKIAAOvr69jY2JeXl7GxsQCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPUaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkDALYwEC1Uy6nySlL+kUGa9VFALPNHWMt8Dgub4aB5LQCcBgI'.
'/FxieHI+YneHZzYOBwB/DzqCXnN2X2dRdTN6AxiNgUJAPyWajA'.
'N8AZ40haEeegYCAiuoq7Mco20WqEW6E4pWFqUHp247NwTGx8jJ'.
'ybTErWsWwsMfytTUzL0Nf7CLK8XV38bXuDpFkLi76Ivju+a07k'.
'Oz6fLzEwkAOw=='.
'');
break;
case 6:
    header("Content-length: 281");
    echo base64_decode(
'R0lGODlhRgAUAKIAALu7u6mpqZiYmNra2gCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPeaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkCAYWgEPXbGGQQXDXxxMnbdsD9iBQ7chSsHL69Jq9lqoCcNAC'.
'BgFuU3SEZEBlYYVoDFgBAW1bR19SLHiUT5V2hFQ6C2sWA5E7IW'.
'I/JXoGWAN8fYIleKannQqNBgFqrrG6IrMGfIG3oTkrvUXGaTe9'.
'AllZuQYE0NHS09TRP6OovhfCw9jV3+DXiw6PD1x54OnT4nnFE+'.
'fux/LjOPC79xij1/L8/SkJADs='.
'');
break;
case 7:
    header("Content-length: 265");
    echo base64_decode(
'R0lGODlhRgAUAKIAAKioqMDAwODg4JqamgCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPOaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hcBARYbEC1Uy6nySlL+kUGa1WFICPgiptmnhf4bNHhtsYAwF8P'.
'3EBggj5iYXKDeQ8AB1uATmRSkGVRglQ6DmsPOiVxPyVpVoyaKz'.
'SEnh6gapeAp60iqwoDB22jO7BFuA6JDIuNuqQGBMLDxMXGxp+7'.
'ob6swcfP0MLJFqkTm9TR2cgnyinXt7nhttUS367nGLY/4uztEw'.
'kAOw=='.
'');
break;
case 8:
    header("Content-length: 283");
    echo base64_decode(
'R0lGODlhRgAUAKIAANbW1uvr66CgoLm5uQCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPgaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkDAKHwMCha7YwyGDY6+ONk7aGwDKwCFS7sjSsnD6/56+lqmhv'.
'/XBTdoNlQGZihGkMawAGAAdvOUdgUix6lU+WeINUOlYXW4FChj'.
'8nngprB22QojSFpSKnjqyMrbC3HHyzW7WSO7JFwVx7sm0BAlih'.
'C117BM7P0NHS09C5igyPFo2tBtTe39HWxA8C5Q/MN+Dq3uI3wB'.
'PowvLn48HouPgYvz/z/f4TCQAAOw=='.
'');
break;
case 9:
    header("Content-length: 284");
    echo base64_decode(
'R0lGODlhRgAUAKIAAPX19bm5uZ+fn9ra2gCZMwAAAISEhP///y'.
'H5BAAAAAAALAAAAABGABQAAAPhaLrc/jDK2Y69OOvN+zVep4Rk'.
'SYJUNR5FW5iZ+5Lzd6TMDbJWDfM9WgaFG61mL9nF1fPVkkxmEE'.
'hkBACHgcCha7YwyGDY6+ONk7ZGwDI4ALjH2BcIndOX37O9qmgH'.
'DGt/OXFLU2FlQGZihol8Bm1bAlkqO05SLHOXT5h5jFQ6C2tabQ'.
'OUJWM/JY4GWG6Tgzs0iKkioFYBoqa0ux6OAgFbgbq2RcUPaVZu'.
'VwdbsB8E0NHS09TV1hixq23KcNnW3+Df2MgNAs3dz+Hq6uMWqx'.
'Nd7sbzXO7EFPG8+kO79P7/ExIAADs='.
'');
break;
}
return;
}
?>

Usage:

1. save above code as pr.php
2. upload it to your website eg: /public_html/ or /htdocs/
3. open your web site: www.yourwebsite.com/pr.php
4. check the url using: www.yourwebsite.com/pr.php?q=www.facebook.com

Demo: http://www.booser.com/pr-checker/pr.php?q=www.facebook.com
Note: You can replace the www.facebook.com with your website URL.

Download: PageRank Checker Script 2011

Hope that help.

How to install FFMPEG/MPlayer Automatically

Its been long time i did not update this blog, here i found some useful ffmpeg installer that will automatic install them for you by douwnloading and installing its dependecies files.

This script will install the following packages in your server:

ffmpeg
Mplayer
A52decoder
Amrnb and Amrwb
All codecs
facc and faad2
Ruby
flvtool2
ffmpeg-php
Mplayer and Mencoder
Lame
Libogg
Libvorbis
Libtheora
Libwmf
opencoreamr
vorbistools
X264
MP4Box
Xvidcore

Download URL is:
ffmpeginstaller Latest Stable Release : ffmpeginstaller.7.1.tar.gz

after download,

extract it by:

 

tar zxvf ffmpeginstaller.7.1.tar.gz

sh install.sh

Source from: http://www.ffmpeginstaller.com

then it will install everything for you. Cheers

UNIX Disk Usage Command Examples

How do I find out disk usage under UNIX operating systems using GUI, CLI and Perl / shell programs?

You need use the command line utility called du to displays the file system block usage. In this example find out /tmp dir disk usage statistics (open the terminal and type the following command):
$ du /tmp
Sample outputs:

4	/tmp/vmware-root
8	/tmp/pulse-xc7xdoM9vB2K
4	/tmp/.X11-unix
4	/tmp/keyring-7qXGnQ
4	/tmp/.exchange-vivek
4	/tmp/.winbindd
8	/tmp/plugtmp
4	/tmp/virtual-vivek.C81Sd0
4	/tmp/VMwareDnD
4	/tmp/ssh-mhNeIv1961
4	/tmp/.ICE-unix
8	/tmp/orbit-vivek
4	/tmp/.esd-1000
31644	/tmp

The -h option provides “Human-readable” outpu i.e. you will see it in Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte:
$ du -h /tmp
Sample outputs:

4.0K	/tmp/vmware-root
8.0K	/tmp/pulse-xc7xdoM9vB2K
4.0K	/tmp/.X11-unix
4.0K	/tmp/keyring-7qXGnQ
4.0K	/tmp/.exchange-vivek
4.0K	/tmp/.winbindd
8.0K	/tmp/plugtmp
4.0K	/tmp/virtual-vivek.C81Sd0
4.0K	/tmp/VMwareDnD
4.0K	/tmp/ssh-mhNeIv1961
4.0K	/tmp/.ICE-unix
8.0K	/tmp/orbit-vivek
4.0K	/tmp/.esd-1000
33M	/tmp

df: Display Free Disk Space

To show statistics about the amount of free disk space on the specified file system or on the file system of which file is a part use the df command as follows:
$ df
$ df -h

Sample outputs:

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a      938M   43.0M    848M     5%    /
/dev/wd0e      817M    2.0K    776M     0%    /home
/dev/wd0d      2.9G    573M    2.2G    20%    /usr

Google PageRank checker script PHP

You had seen many google pagerank checker site, you might wonder how they do it? Here is the script that do the tricks.

It will show the pagerank with a graphic bar that generate using GD and numeric page rank.
Download

Google Pagerank checker script

Downloads: 528 File Size: 3.1 KiB
Updated : August 19, 2010
Usage:
pr.php?prurl=http://www.booser.com

Hope that help.

Update: New version of Page Rank Checker script 2011

Automatic File + Database Backup Script PHP

This is a pure php implementation of a php backup script. So it should work fine on windows and linux. But its not suited for takeing very large backups.

I just wrote it cause most of the script i saw offered file or database backup and broke down to usage of exec  and unix commands , for which i had to contact hosting.

Some basic features -

  • File and Directory backup
  • Multiple database/table sql backup
  • Backup email

Download
PHP Backup Script

Downloads: 9,230 File Size: 11.8 KiB

Updated : August 19, 2010
The script is supposed to be called using automatically using CRON , and the backup folder in which backup it taken should be writable.All you have to do is run backup.php .Edit config.php before use. Released under GNU GPL license.

How to prevent ddos attack

It is pain of hell when some one ddos your server, it will eat all your bandwidth, here is a method to prevent ddos attack using software based protection, if packet goes large, you still need hardware based ddos protection.

Install DDos Deflate

Login to your server as root

cd /usr/local/src
wget http://www.inetbase.com/scripts/ddos/install.sh
sh install.sh

you need to have APF or iptables installed on your server, please configure it at:
/usr/local/ddos/ddos.conf with your favorite editor for example

nano /usr/local/ddos/ddos.conf

Hope that help.

How to install Git

Git is distributed version control system focused on speed, effectivity and real-world usability on large projects. In this post i will show you how to install git, you might require this tool for installing x264 or other tool that might require git to grab file.

wget http://kernel.org/pub/software/scm/git/git-1.7.3.tar.bz2
tar jxvf git-1.7.3.tar.bz2
cd git-1.7.3
./configure
make && make install 
git

You are done, hope that help.

Wrong diskspace and information in cPanel

Wrong diskspace and information in cPanel

cPanel keeps disk space usage for your entire account, email accounts, databases, and other features. These are cached for faster interactions. They will refresh once every day.

If you purge many emails from trash and can see that the folders are empty, then the emails are really gone and not using disk space. Your cPanel may still show few MB being used, but this will be updated within 4 hours.

If you import a database and can see all of the tables and data, then the data is saved and is using disk space. cPanel may still show 0 MB, but this will be updated within 4 hours.

From WHM, if we increase the total disk space for an account, and WHM shows the increase, then the account can use the new disk space immediately. Inside cPanel it may still show the old disk space limit, but this will update automatically within 4 hours.

How to install Config Server Firewall


What is config server firewall? CSF is A Stateful Packet Inspection (SPI) firewall, Login/Intrusion Detection and Security application for Linux servers.

Supported and Tested Operating Systems
RedHat v7.3, v8.0, v9.0
openSUSE v10, v11
RedHat Enterprise v3, v4, v5 (32/64 bit)
Debian v3.1, v4.0, v5.0
CentOS v3, v4, v5 (32/64 bit)
Ubuntu v6.06 LTS, v8.10, v9.10, v10.04 LTS
Fedora Core v1 to v12(32/64 bit)
Mandriva 2009, 2010
Gentoo
Slackware v12.2

(* may require custom regex patterns for some functions)

Supported and Tested Virtual Servers
Virtuozzo
OpenVZ
VMware
UML
Xen
MS Virtual Server
VirtualBox

Here is how to install it:

cd /usr/local/src
rm -fv csf.tgz
wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Hope that help

Search and Replace Text String in MySQL Database with phpMyAdmin

Sometime you might facing problem to replace the string or data in mysql and you have many row inside your table.  Here is the solution you can put in to SQL command line in phpmyadmin, this solution is work for mysql too.  Before begin please back all your sql 1st, in case you make any mistake.

Open phpmyadmin -> click on database -> click on table name -> click on SQL tab on top then enter the command below:

UPDATE tablename SET field = replace(field, "SearchString", "ReplaceString");

please change:
tablename
field
SearchString
ReplaceString

according your table name and field.
you can also add where Clause ( add condition for this sql statemen )

UPDATE tablename SET field = replace(field, "SearchString", "ReplaceString") WHERE field2='SomeValue';

Hope this help..

Disable open_basedir in Plesk

Disable open_basedir in Plesk

This explanation tells you how to disable open_basedir in plesk without breaking/commenting your current httpd.conf basedir lines.

Create a new file, called vhost.conf
This file will include anything you want to disable from httpd.conf main config from your virtual host.

touch /var/www/vhosts/yourdomain.com/conf/vhost.conf

Now we edit the file and we add the following,

/var/www/vhosts/yourdomain.com/conf/vhost.conf
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir none

Once you finish adding the mentioned lines, its time to reconfigure and restart the webserver config.

/usr/local/psa/admin/sbin/websrvmng -v -a

You should be done by now.

Securing and Hardening PHP

Securing and Hardening PHP

secure php

PHP as a module or as a CGI

Using PHP as a module is suitable for systems that are dedicated to a single purpose or for sites run by trusted groups of administrators and developers. Using PHP as a CGI (possibly with an execution wrapper) is a better option when users cannot be fully trusted.

When PHP is installed as a module, it becomes a part of Apache and performs all operations as the Apache user (usually httpd).

Using PHP as a CGI

Compiling PHP as a CGI is similar to compiling it for the situation where you are going to use it as a module. This mode of operation is the default for PHP, so there is no need to specify an option on the configure line.

Migrating from a module to CGI operation, therefore, requires modifying every script.

register_globals and allow_url_fopen

register_globals.

allow_url_fopen.

Because of security reasons, we turn off these options in the php.ini file:

allow_url_fopen = Off
register_globals = Off

PHP uses modules to extend its functionality dynamically. Unlike Apache, PHP can load modules programmatically using the dl( ) function from a script. When a dynamic module is loaded, it integrates into PHP and runs with its full permissions.

enable_dl = Off

Use the expose_php configuration directive to tell PHP to keep quiet.

Setting this directive to Off will prevent the version number from reaching the Server response header and special URLs from being processed:

expose_php = Off

The PHP configuration directives disable_functions and disable_classes allow arbitrary functions and classes to be disabled.

The most useful security-related PHP directive is open_basedir. It tells PHP which files it can access.

Given that web server root, here is how open_basedir should be set:

open_basedir = /var/www/

When PHP is compiled with a –enable-memory-limit, it becomes possible to put a limit on the amount of memory a script consumes. Consider using this option to prevent badly written scripts from using too much memory. The limit is set via the memory_limit option in the configuration file:

memory_limit = 8M

You can limit the size of each POST request. Other request methods can have a body, and this option applies to all of them. You will need to increase this value from the default value specified below if you plan to allow large file uploads:

post_max_size = 8M

The max_input_time option limits the time a PHP script can spend processing input.

max_input_time = 60

The max_execution_time option limits the time a PHP script spends running.

max_execution_time = 30

File uploads can be turned on and off using the file_uploads directive.

file_uploads = Off

Safe mode (http://www.php.net/manual/en/features.safe-mode.php) is an attempt of PHP developers to enhance security of PHP deployments. Once this mode is enabled, the PHP engine imposes a series of restrictions, making script execution more secure.

PHP safe mode is a useful tool. We start by turning on the safe mode

safe_mode = On

Safe mode puts restrictions on external process execution. Only binaries in the safe directory can be executed from PHP scripts:

The following functions are affected:

• exec( )
• system( )
• passthru( )
• popen( )

Some methods of program execution do not work in safe mode:

shell_exec( ) Disabled in safe mode.
backtick operator Disabled in safe mode.
dl( ) Disabled in safe mode.

Hardened-PHP (http://www.hardened-php.net) is a project that has a goal of remedying some of the shortcomings present in the mainstream PHP distribution.

Reference – http://www.php.net