Change php error reporting to hide warnings for specific site only <p>Imagine a couple of <code>sites-enabled</code> available from <code>/etc/apache2/sites-available</code>. (Only Debian-based distros work like this.)</p> <p>Is it possible to mute <code>warning</code> messages from php scripts from <em>a specific site</em>, without touching the actual <code>htdocs</code>?</p> <p>Normally there are a couple of solutions to achieve someting related:</p> <ol> <li>Add an <code>error_reporting()</code> directive e.g. <code>error_reporting(E_ERROR);</code> to the scripts executed.</li> <li>Set php_flags in <code>.htaccess</code> files like so: <code>php_flag display_errors off</code></li> <li>Use <code>ini_set</code> inside scripts:<br> <code>ini_set('display_errors', 'Off');</code><br> <code>ini_set('display_startup_errors', 'Off');</code><br> <code>error_reporting(0);</code></li> <li>Prepend <code>@</code> to functions that throw warnings or errors.</li> <li>Change <code>php.ini</code> to actually say<br> <code>error_reporting = E_ALL ^ E_WARNING</code><br> <code>display_errors = 1</code> </li> </ol> <p>However, these all mean touching the htdocs or having the change applied globally. Imagine the <code>htdocs</code> are mounted read-only. How would I suppress warnings (or notices) for certain sites only?</p> <p>I am assuming Debian/Ubuntu has <code>a2ensite</code> specific configurations for a reason and I am hoping I can alter those. There is a <code>log_level</code> directive in the example 'site available' configuration, but this handles the amount of messages logged. Not the messages output by the php scripts.</p> <p>Manually adding sections in <code>php.ini</code> or <code>apache2.conf</code> or <code>httpd.conf</code> will also work. If it is possible.</p> <p>See also:</p> <ul> <li><a href="http://www.php.net/manual/en/function.error-reporting.php" rel="nofollow">http://www.php.net/manual/en/function.error-reporting.php</a></li> </ul>