依赖/tmp文件夹的可写性可以吗?
可以假设 PHP/Apache 在任何 UNIX 系统上都可以写入 /tmp 文件夹吗? 我正在制作一个脚本,想要将缓存保存在 tmp 文件夹中,并想知道这是否会导致问题。
Is it ok to assume /tmp folder writable by PHP/Apache on any unix system?
I'm making a script and want to save cache in the tmp folder and want to know whether that can cause problems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应该没问题。
/tmp
是为每个人使用而设计的。但要小心,这也意味着如果您不设置特定权限,任何人都可以读取您的文件!如果您不确定,请让安装脚本检查
/tmp
文件夹,并使用户可以配置另一个临时位置。无论如何,这可能是最好的选择,因为不同的用户有不同的需求。例如,考虑具有负载平衡服务器的用户;她可能想要使用在所有主机之间共享的文件夹。It should be OK.
/tmp
is made for everyone to use. But be careful, it also means that anyone can read your files if you don't set specific permissions!If you are unsure, make your installation script check the
/tmp
folder and make it possible for the user to configure another temp location. This is probably the best bet anyway because different users have different needs. Consider for example a user with load-balanced servers; she might want to use a folder which is shared between all her hosts.您不能依赖 /tmp 文件夹,就像在 Linux 的某些变体中一样,它会在一段时间后自动清理,您的应用程序最好在应用程序内有一个本地 tmp 文件夹,您可以自己管理该文件夹。
You can not rely on /tmp folder as in some variations of linux, it is auto cleaned after some time, it would be best for your application to have a local tmp folder inside the app, which you manage yourself.