Take the 2-minute tour ×

I've just bough VPS account for testing and development.

Is there a function of PHP to parse Apache config file, PHP config, FTP Server config, zone files, etc? 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). If you have done it before - how did you do it?

It would be quite challenging to learn


share|improve this question
Is parse_ini_file() the function you are looking for? –  Pete171 Sep 26 '11 at 8:34
add comment

3 Answers

up vote 2 down vote accepted

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. However, for php.ini you might be able to use PHP's ini functions.

Most webhosting control panels either create the whole config file based on their database - i.e. 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.

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.

share|improve this answer
thanks for answer. You say "create the whole config file based on their database" - That is interesting and I didnt know that can be done.. Where I can look into this more details? Thanks. –  I'll-Be-Back Sep 26 '11 at 9:16
It means simply writing the whole config file. Some applications can take config data directly from a DB though (some ftp servers for example) –  ThiefMaster Sep 26 '11 at 9:20
Ahh I understood what you meant now.. cool idea. Thanks! –  I'll-Be-Back Sep 26 '11 at 9:26
add comment

You may be able to use the follow pear library to parse apache config files:


Parsing a php.ini file, depending on what you want to do, is probably best done with ini_get

share|improve this answer
add comment

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. 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.

For the PHP configuration the following functions will probably do the trick:

Bare in mind however that not all PHP configuration directives can be changed with ini_set().

share|improve this answer
add comment

Your Answer


