I want to execute a script when a PUT request is received from my Apache server.
For example - I want scan the uploaded file using clamAV antivirus when client uploads a file.
How can this be done?
modsecurity can do that, ClamAV example is given in official documentation.
modsecurity is de-facto standard and is actively supported by community and TrustWave inc security experts with spiderlabs, it's like main part for OWASP project for years. Provided as both hardware appliance and software products, widely used in financial institutions, banks, processing centers. You can try mod_clamav, but would you trust software maintained by one guy with last update in 2009 and version 0.xx? :)
With mod_actions (which usually comes as standard in most distributions) you can map http methods to script handlers:
Script PUT yourhandler.xx
The data arrives on STDIN - there's a chapter in PHP manual demonstrating how to implement this.
(or you can use mod_rewrite to change the method to whatever, and the URL to your handler - once again reading data from stdin)