26

How exactly can the ServerAdmin directive in Apache2 be useful?

The Apache2 documentation reads:

The ServerAdmin sets the contact address that the server includes in any error messages it returns to the client.

But whenever I get a 404 Error back, the email address set in my vhost is nowhere to be seen. Do I need some extra Directive to make it work?

vhost:

<VirtualHost *:8080>
    ServerAdmin myemail@gmail.com
    ServerName testsite.example.com
    DocumentRoot /var/www/example.com/www
</VirtualHost>
Enrique Moreno Tent
  • 24,127
  • 34
  • 104
  • 189
  • 2022 update: it's required by `mod_md`, which uses it to register you at a Certificate Authority when getting a TLS certificate. The CA may or may not use it to contact you. – EML Jun 20 '22 at 11:07
  • This question is probably more suitable to "Unix and Linux" https://unix.stackexchange.com/ – Valerio Bozz Jan 25 '23 at 11:58

2 Answers2

25

Apparently that functionality of Apache has been deprecated. I used to see a message in the event of an error to contact the server administrator, but now can't get it to happen on the current versions.

As an answer to your question "how can it be useful"; you can get the value with PHP at least $_SERVER['SERVER_ADMIN'] and return that from your code in the event of an error.

Joe T
  • 2,300
  • 1
  • 19
  • 31
1

As default the ServerAdmin information is not displayed on error messages.

You can display this information enabling the ServerSignature directive to the email value:

ServerAdmin foo@example.com
ServerSignature email

Relevant documentation:

https://httpd.apache.org/docs/current/mod/core.html#serveradmin

https://httpd.apache.org/docs/current/mod/core.html#serversignature

Then remember to restart your Apache HTTPd server:

systemctl restart apache2

NOTE: You can also use an URL, instead of an email. That's very useful if you have a contact page instead of an email address.

Valerio Bozz
  • 1,176
  • 16
  • 32