在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

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

问题描述

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

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 目录,其中有所有的phps。只要把它放在那个目录之外。

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天全站免登陆