Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Permissions on PHP script to only run locally



Dave,

> I have a PHP script that runs a backup of some site files and emails me
> a tar.gz file once a day. It's activated by cron on the webhosting server
> 
> I wondered if there was a permission setting I could put on the file so
> that it was only accessible by the server's local cron command, and not
> accessible by anyone coming at it from the browser.

The best solution is to put this php script out of the web server
DocumentRoot (Apache terminology). For example, if your web server
distributes files located in the /var/www/example.com/ directory, and
your bachup script is now located at /var/www/example.com/foo/backup.php, 
you should remove this file and save if in
/home/dave/scripts/backup.php for example.

There, no one can execute this script through the web server. But you
can still run it with a cron line

# m h  dom mon dow   command
  6 42 *   *   *     /usr/bin/php /home/dave/scripts/backup.php

-- 
Nicolas LIMARE
smtp:nicolas@example.com                            pgp:0xFA423F4F
xmpp:nicolas@example.com              http://nicolas.limare.net

Attachment: signature.asc
Description: Digital signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links