When a config option is set twice...

I'm assuming the answer to this question is yes, but I thought I'd ask…

With:

/etc/ssh/sshd_config

/etc/apache2/apache2.conf

/etc/php5/apache2/php.ini

/etc/mysql/my.cnf

/etc/postfix/main.cf

If a config setting, like MaxClients, is declared twice, OpenSSH/Apache/PHP/MySQL/Postfix will all go with whatever the second config setting says, right?

6 Replies

Config files ONLY apply to their OWN application.

Sorry, poorly worded. Let me clarify.

With OpenSSH, Apache, PHP, MySQL, and Postfix, if you declare a variable twice in their config files, it will always go with the second declaration, right?

It depends on the individual application. Generally, yes, but you should test it yourself by setting something and then setting it again to something different and seeing which applies.

@jzimmerlin:

Sorry, poorly worded. Let me clarify.

With OpenSSH, Apache, PHP, MySQL, and Postfix, if you declare a variable twice in their config files, it will always go with the second declaration, right?

It depends on how they parse their configuration files, and may also depend on other settings. It's usually undefined behavior. The best case is that the application will refuse to start until it's fixed; the next-best case is that it will throw an error, tell you what it has chosen to do, and proceed accordingly.

If you're relying on predictable behavior, you're probably going to have to do some testing.

Would search/replace be the only other way to automate setting config options for OpenSSH/Apache/PHP/MySQL/Postfix using a shell script?

I usually use the template approach (via chef, but other configuration management systems do similar things). eRuby/erubis is well-suited to this sort of thing.

It's essentially search-and-replace, but with more smarts.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct