Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking to run a PHP script with a cron job, but it seems I don't have a PHP binary. Looks like I don't have PHP installed as a CGI, so without reinstalling/configuring my PHP, what is the best way to run a php file? I would prefer to not have the file public facing, so some solutions like wget seem a bit hacked. Thank you!

share|improve this question

3 Answers 3

You are going to have to pick one. Install the cli/cgi binary or use wget/curl to make a request to your web server.

If you want to protect the script you could adjust the configuration of the web server to block access except from local host, or add something to the script to return an error if the request didn't originate from the local host.

Of course you could also translate the script into something else, but if you need to use libraries common to a web app this is probably not worth the effort.

share|improve this answer
    
The CLI Binary is what i always use, either that or learn some bash ;) –  GruffTech Aug 18 '10 at 18:14

Looks like I will just protect it, as Zoredache mentioned. For future peeps here is a good link that answered most of my questions about the Apache module vs. CGI binary: http://www.how2dev.com/running-php-scripts-using-cron/

My only concern was that a public facing link would not be immune to denial of service attacks, but only allowing localhost sounds like the answer to mitigate that. Thank you!

share|improve this answer

You can compile PHP Scripts to Executables... http://wiki.swiftlytilting.com/Phc-win

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.