简体   繁体   English

如何解析Apache配置文件,PHP配置,FTP服务器配置

[英]How to Parse Apache config file, PHP config, FTP Server config

I've just bough VPS account for testing and development. 我只是使用VPS帐户进行测试和开发。

Is there a function of PHP to parse Apache config file, PHP config, FTP Server config, zone files, etc? PHP是否具有解析Apache配置文件,PHP配置,FTP Server配置,区域文件等的功能? Also a way to insert data into config file. 这也是将数据插入配置文件的一种方法。

I want to create a simple Control Panel to add ftp accounts and web account (with domain). 我想创建一个简单的控制面板以添加ftp帐户和Web帐户(具有域)。 If you have done it before - how did you do it? 如果您之前曾经做过-您是怎么做的?

It would be quite challenging to learn 学习将非常具有挑战性

Thanks. 谢谢。

You may be able to use the follow pear library to parse apache config files: 您可能可以使用follow pear库来解析apache配置文件:

http://pear.php.net/manual/en/package.configuration.config.avail-container.apache.php http://pear.php.net/manual/en/package.configuration.config.avail-container.apache.php

Parsing a php.ini file, depending on what you want to do, is probably best done with ini_get 根据您要执行的操作来解析php.ini文件,最好使用ini_get完成

No, PHP has no functions to parse the config files of those programs - you'll have to write a custom parser for most of those formats. 不,PHP没有解析这些程序的配置文件的功能-您必须为大多数格式编写一个自定义解析器。 However, for php.ini you might be able to use PHP's ini functions. 但是,对于php.ini,您也许可以使用PHP的ini函数。

Most webhosting control panels either create the whole config file based on their database - ie they never read it but only (over)write it or they require you to include (apache and bind support that for example, for PHP you can use php_admin_value in the apache virtualhosts) their generated file - which is also never read by the tool. 大多数网站托管控制面板要么根据其数据库创建整个配置文件-即他们从不读取它,而仅(覆盖)它,或者它们要求您包括(Apache和绑定支持,例如,对于PHP,您可以在其中使用php_admin_value apache virtualhosts)生成的文件-该工具也永远不会读取。

If you really want to create a tool that actually modifies existing files, don't forget that you cannot simply skip comments as nobody would want an application to rewrite his config file stripping all comments. 如果您真的想创建一个可以实际修改现有文件的工具,请不要忘记您不能简单地跳过注释,因为没人会希望应用程序重写其配置文件以剥离所有注释。

I'm not aware of such functions and I highly doubt they exist for the simple reason that there are just too many HTTP / FTP / SMTP / ... server implementations. 我不知道这些功能,我非常怀疑它们是否存在,其原因很简单,那就是HTTP / FTP / SMTP / ...服务器实现太多。 Control panels like cPanel, WebMin and others usually do the heavy lifting for you and some even provide an API to automatize things from PHP. 控制面板,例如cPanel,WebMin和其他通常会为您带来繁重的工作,有些甚至提供了API以自动执行PHP中的操作。

For the PHP configuration the following functions will probably do the trick: 对于PHP配置,以下功能可能会解决问题:

Bare in mind however that not all PHP configuration directives can be changed with ini_set() . 但是请记住,并非所有的PHP配置指令都可以使用ini_set()进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM