在 linux/apache 服务器上的 cron 作业上运行 script.php,但限制对 php 文件的公共访问 [英] Run a script.php on cron job on linux/apache server but restrict public access to the php file

查看:18
本文介绍了在 linux/apache 服务器上的 cron 作业上运行 script.php,但限制对 php 文件的公共访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 script.php 文件,我想在我的 linux/apache 服务器上将其作为 cron 作业运行.

I have this script.php file which i want to run as a cron job on my linux/apache server.

但是,我不希望公众访问 www.mycompanyname.com/script.php 并同时运行脚本.

However, i do not want public to access www.mycompanyname.com/script.php and also run the script concurrently.

我们如何防止这种情况发生?我们如何限制脚本只能访问服务器?是使用 chmod 还是在 .htaccess 文件中设置了一些东西?

How can we prevent that? How can we restrict the script to the server's access only? Is it using chmod or setting something inside .htaccess file, something along the line?

有什么建议吗?

推荐答案

您可能有一个类似于 public_html 的目录,其中包含所有 php.把它放在那个目录之外.

You probably have something like a public_html directory, in which you have all the phps. Just put it outside of that directory.

这篇关于在 linux/apache 服务器上的 cron 作业上运行 script.php,但限制对 php 文件的公共访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆