lukinagin Posted July 3, 2007 Share Posted July 3, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/58309-eliminating-the-shebang-from-a-php-script-running-as-a-cli/ Share on other sites More sharing options...
trq Posted July 3, 2007 Share Posted July 3, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/58309-eliminating-the-shebang-from-a-php-script-running-as-a-cli/#findComment-289219 Share on other sites More sharing options...
trq Posted July 3, 2007 Share Posted July 3, 2007 Ah... what was I thinking? Making it recurse is easy. Run this from your web root to prepend the shebang into all your php files. for f in $(find . -name '*.php') ; do echo -e '#!/usr/local/php5/bin/php\n'$(cat $f) > $f ; done Quote Link to comment https://forums.phpfreaks.com/topic/58309-eliminating-the-shebang-from-a-php-script-running-as-a-cli/#findComment-289229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.