Howto PHP / Java bridge on Debian

Updated 20. Marts 2007

The PHP / Java Bridge makes it possible to run use java objects within your PHP code. For example; let’s say you have a jar-file containing some functionality you may want to use in a PHP application.

To use this you must have a Java installed – either the latest version of Java (JDK) or a black hawk version installed.

Get the source code php-java-bridge_3.0.4.tar.bz2 from the PHP / Java bridge website and unpack it with


tar xvjf php-java-bridge_3.0.4.tar.bz2

cd php-java-bridge-3.0.4

phpize - in order to use this you'll need to have the php5-dev package installed

./configure --with-java=/usr/lib/j2sdk1.5-sun - be sure to set this to the path where the Java installation is located

If the ./configure command fails because the automake version is less than 1.6 try this

apt-get install automake1.6
update-alternatives --config automake

Select version 1.6 of automake in the update-alternatives dialog and then try to run ./configure again

Now we just need to compile and install, this is done by:

make install-modules

Add this line to php.ini in order to enabled the PHP/Java bridge extension:

Comments off

BisonCam ( ALi M5603C ) Linux driver round up

I have written this as a round up on my search for a Linux driver for the built-in webcam in my Asus A3N series notebook. The built-in webcam in my book is built on a micro chip from Ali and it is named m5603c, more in general the chip is sometimes refered to as m560x. I found that this m560x chip is used in a lot of different devices and even other notebooks like the Asus A6 series.

Right now – it seems that there are a few projects focusing on creating a driver for m560x chip, currently I have noticed these ones.

  • SANE m5603c backend
  • Ali M560x Linux Driver Project
  • ALi USB2 M5603C Video Camera Controller – Seems stalled

Until now I have assembled this list of devices that are build upon the m560x chip.

  • Asus Z9100G notebook series
  • Sweex webcam
  • Asus A6 notebook series
  • Q-TEC Webcam 300 USB 2.0
  • Trust SpaceC@m 360
  • Creative Live Pro
  • USB 2.0 Webcam 1.3 Megapixel
  • Genius VideoCam Slim USB2

Please leave a comment – if you know a device or driver project not listed here


Block referer spam easily

I have built this small tutorial because somebody kept requesting different urls on the server with referer spam. The tutorial shows how to block referer spamon a Debian 3.1 server with a apache 2 webserver by using mod_security

Install mod_security

debian21:~# apt-get install libapache2-mod-security
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
The following NEW packages will be installed:
  libapache2-mod-security mod-security-common
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 274kB of archives.
After unpacking 737kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 stable/main mod-security-common 1.8.7-1 [240kB]
Get:2 stable/main libapache2-mod-security 1.8.7-1 [34,4kB]
Fetched 274kB in 0s (682kB/s)
Selecting previously deselected package mod-security-common.
(Reading database ... 28605 files and directories currently installed.)
Unpacking mod-security-common (from .../mod-security-common_1.8.7-1_all.deb) ...
Selecting previously deselected package libapache2-mod-security.
Unpacking libapache2-mod-security (from .../libapache2-mod-security_1.8.7-1_i386.deb) ...
Setting up libapache2-mod-security (1.8.7-1) ...
Setting up mod-security-common (1.8.7-1) ...


Enable the newly installed module

debian21:~# a2enmod mod-security
Module mod-security installed; run /etc/init.d/apache2 force-reload to enable.


Add this setup to your apache2.conf or your .htaccess file

<ifmodule mod_security.c>
    # Turn the filtering engine On or Off
    SecFilterEngine On

    # Make sure that URL encoding is valid
    SecFilterCheckURLEncoding On

    # Unicode encoding check
    SecFilterCheckUnicodeEncoding Off

    # Only allow bytes from this range
    SecFilterForceByteRange 0 255

    # Only log suspicious requests
    SecAuditEngine RelevantOnly

    # The name of the audit log file
    #SecAuditLog logs/audit_log
    # Debug level set to a minimum
    #SecFilterDebugLog logs/modsec_debug_log
    #SecFilterDebugLevel 0

    # Should mod_security inspect POST payloads
    SecFilterScanPOST On

    # By default log and deny suspicious requests
    # with HTTP status 500
    SecFilterDefaultAction "deny,log,status:500"

    # Block request with suspicious referers
    SecFilterSelective "HTTP_REFERER" "(holdem|poker|casino|porn)" deny,nolog,status:500


And then restart apache

debian21:~# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2.


Then run a few test requests to ensure it works as we intended it to

debian21:~# wget http://localhost/ --referer=
--15:33:34--  http://localhost/
           => `index.html'
Resolving localhost...
Connecting to localhost[]:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
15:33:34 ERROR 500: Internal Server Error.



It blocks the request just like we thought it would.


debian21:~# wget http://localhost/ --referer=
--15:33:43--  http://localhost/
           => `index.html'
Resolving localhost...
Connecting to localhost[]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,009 [text/html]

100%[========================================>] 1,009         --.--K/s

15:33:43 (9.62 MB/s) - `index.html' saved [1009/1009]



The request passed right trough as intended ;)

And we are done.
This is only one way of preventing referer spam, some others have done a similar block by using the built-in Linux firewall called iptables. Perhaps more on using iptables as blocking mechanism another time.

Comments off