什么是用PHP写的linux系统文件的最佳途径 [英] What's the best way to write to linux system files using PHP

查看:117
本文介绍了什么是用PHP写的linux系统文件的最佳途径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要一些脚本生成的配置文件的网​​络服务,如根据用户输入DHCP,DNS和网络。这些都需要root权限,但我不知道如何运行PHP应用程序根目录。它是通过公开的网络界面运行。

We need some scripts to generate config files for network services such as DHCP, DNS and Network based on user input. These require root access, but I don't know how to run the PHP application as root. It's run through a public web interface.

推荐答案

呀,授予root用户权限到PHP或Web服务器从来都不是一个很好的做法,不管如何保护您的安装。

Awww... granting root rights to PHP or the web server is never a good practice, no matter how secure your setup.

如何让PHP写更改配置文件到一个临时目录:

How about having PHP write the changed configuration files into a temporary directory:

/home/system/transfer/apache/httpd.conf
/home/system/transfer/system/dhcp.conf
/home/system/transfer/mysql/my.ini

须藤 cron作业运行shell脚本从那里下载他们,将它们复制到合适的位置(也考虑重新启动服务的关怀和所有),上一个五分钟的依据是什么?

and a sudo cron job running a shell script fetching them from there, and copying them to the proper location (also taking care of restarting services and all that), on a five-minute basis?

这会比具有网络/ PHP的用户直接写配置文件更安全一点,再加上它会相对容易建立一个版本的过程,允许回滚一个配置文件到一个较早的版本。

It would be a bit safer than having the Web/PHP user write the configuration files directly, plus it would be relatively easy to set up a versioning process that allows to roll back a configuration file to an earlier version.

这篇关于什么是用PHP写的linux系统文件的最佳途径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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