How to Set ServerAdmin Email in Apache

set serveradmin email apache

Apache can be setup to automatically send you emails, in case of internal server errors (response code:500). It is very useful in staying up-to-date about your website health. You can do that by simply setting the ServerAdmin directive. Here’s how to set ServerAdmin email in Apache.


How to Set ServerAdmin Email in Apache

Here are the steps to set ServerAdmin email in Apache. We will use the ServerAdmin directive which sets the contact email address to be included in emails that your server will send, in case of errors.


1. Open Apache Config file

Open Apache config file in a text editor. You will generally find it at one of the following locations, depending on your Linux distribution and type of installation:

  • /etc/apache2/httpd.conf
  • /etc/apache2/apache2.conf
  • /etc/httpd/httpd.conf
  • /etc/httpd/conf/httpd.conf


$ sudo vim /etc/apache2/httpd.conf


2. Set ServerAdmin Email

Simply add the ServerAdmin directive to your config file

Syntax :

ServerAdmin email-address|URL



You can use it in server config file as well as virtual host files. You can also point it to a URL but for our tutorial, we will be setting it to an email address.

Here’s the documentation about ServerAdmin directive.


3. Restart Apache web server

Restart Apache web server to apply changes

$ sudo /etc/init.d/apache2 start [Debian or Ubuntu]
# sudo apachectl restart [RHEL, CentOS or Fedora]


That’s it! Now every time your server encounters an internal error, Apache will automatically send you an email with its stacktrace details. Please note, you won’t receive emails in case of broken links, or HTML errors. These emails will be sent only if there is an internal error in your back end code.


About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!