Jump to content

Eliminating the shebang from a PHP script running as a CLI


Recommended Posts

I have compiled Apache 2.2.4 and PHP 5.2.2 on a Solaris 10 machine successfully.  I've compiled PHP as a CLI to take advantage of Apache's suexec feature.  I am now able to successfully run a PHP script as a CLI as long as I add in a #!/usr/local/php5/bin/php line to the beginning of my script.  Since I have a lot of scripts that do not have this shebang entry, I am looking for a way to avoid having to change each and every script.  Does anyone know of a way that I can modify my configuration so that the shebang is automatically inserted when a PHP file is called by Apache?

It would be easy enough to prepend the shebang into all your php files using bash.

 

for f in $(/bin/ls *.php) ; do echo -e '#!/usr/local/php5/bin/php\n'$(cat $f) > $f ; done

 

Getting it to recurse through directories might be a little more work though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.