Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

building PHP as CGI

Status
Not open for further replies.

sonun

IS-IT--Management
Dec 26, 2001
384
US
I am sorry if this post does not conform strictly to the requirements of this pool, but I was encouraged to do so seeing discussion on fastest server side scripting laguages.
The issue is that I have this webcalender (courtsey: freshmeat/sourceforge). Now the calender and everything is set up but there is also a feture for email reminders to be sent and a note on that as follows (which I am not fully able to comprehend!!)
"PHP does not come with a utility for executing time-based jobs. So, in order to check periodically for email reminders, a shell script was written in PHP. You will need two things to get this working: - You should have a version of PHP built as a CGI (so that you can run php from the command line). This does not mean you must build all of PHP as a CGI. You can still build PHP as a module for your web server and then build the CGI-based PHP later.- You must setup cron (on Linux/UNIX) or something like cron for Windows to run the send_reminders.php script periodically.
Building PHP as a CGI is outside the scope of these instructions. But, if you read the PHP instructions, you'll see that the default build settings will build the CGI-based PHP. If you really can't do this (perhaps you don't have permission to install anything new on the
system), skip down a couple of paragraphs to an alternate solution that does not require PHP/CGI.
For Linux/UNIX users, add the following line to the crontab entry of a user. (Ideally, this would be the same user that the web server process runs as, but any user should work.)
1 * * * * cd /some/directory/webcalendar/tools; ./send_reminders.php
Of course, replace the directory location to wherever the
send_reminders.php file can be found. It you moved this out of the tools directory, be sure to update send_reminders.php since it needs to know where to find the WebCalendar files. (It is better for security reasons to move the send_reminders.php file so that it is not accessible from any URL).
If you cannot setup PHP as a CGI or have no idea how, you can leave send_reminders.php in its current location and access it via a URL. IMHO, this is not the best choice, but it still works. Setup a cron job to access the URL. For Linux/UNIX users, add the following line to the crontab entry of a user.
1 * * * * wget > /dev/null
Of course, you should probably test this from the command line first to make sure you setup is correct. If you do not have wget installed on your system, you can use any tool (lynx, perl script, etc.) that is capable of making an HTTP request for this. "
Thanks.
 
Hi,

Does the following test program work ? (Copy to editor, save as whatever, chmod +x filename, then run from command line)


#!/usr/bin/php -q
<?php

print(&quot;Hello, world!\n&quot;);

?>


If so, this means your PHP is already built as cgi capable.

Hope this helps
 
For that, I get,
No such file or directory.
Thanks.
 
Hi,

Have you got this rpm installed ? ftp://rpmfind.net/linux/redhat/7.1/en/os/i386/RedHat/RPMS/php-4.0.4pl1-9.i386.rpm

Try that out...

Otherwise, what php have you got - did you build from source for example...

Regards
 
ok I did that and it works now.
I was a bit confused I already had created some PHP pages on this server which has a Apache and Mysql server running and there was a php.ini file already present on the server,
#whereis php
php: /usr/local/lib/php /usr/local/lib/php.ini
After installtion apart from being able to execute the script, whereis listed,
/usr/bin/php /etc/php.ini /usr/local/lib/php /usr/local/lib/php.ini /usr/share/php

????????????????????????????????????????????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top