Run a script.php on cron job on linux/apache server but restrict public access to the php file(在 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 文件的公共访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 linux/apache 服务器上的 cron 作业上运行 script.php,但限制对 php 文件的公共访问
基础教程推荐
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
