Separate PHP Error Logs for Multiple Domains with Plesk

I’ve put a few additional domains on my Media Temple (dv), and it’s been great. One thing that was bugging me was not having an easy way to tell which domains were generating which scripting errors. When it was just my site, things were easy to follow, but with the addition of a BBS and a couple other WordPress installations, it was getting difficult to tell who was complaining about what.

Solution

You can configure PHP to have a separate error log file for each VirtualHost definition. The trick is knowing exactly how to set it up, because you can’t touch the configuration directly without breaking Plesk.

Every domain name on your (dv) has its own directory in /var/www/vhosts. A typical directory has the following top level directories:

cgi-bin/
conf/
error_docs/
httpdocs/
httpsdocs/
...and so on

You’ll want to create a vhost.conf file in the domain directory’s conf/ folder with the following lines:

php_value error_log /path/to/error_log
php_flag display_errors off
php_value error_reporting 6143
php_flag log_errors on

Change the first value to match your actual installation. After you’re done editing the vhost.conf file, test the configuration from the console with:

apachectl configtest

…or if you don’t have apachectl (as Plesk 8.6 doesn’t seem to)…

/etc/init.d/httpd configtest

And finally tell Plesk that you’ve made this change.

/usr/local/psa/admin/bin/websrvmng -a

You MAY have to tell Apache to restart afterwards. If you see a server connection error, it’s possible that your path-to-error log passed syntax check, but wasn’t writable. Restart it with apachectl restart or /etc/init.d/httpd restart.

Web-Based PHP Error Log Browsing

On my old host, FutureQuest, they had a nice built-in PHP Error Log viewer in the control panel. I thought it would be neat to make something similar, so I created a portable PHP script to help me monitor each domain separately.

To try it out, first download the script, unzip it, and then copy the entire folder to some place on your webserver. Then, point your browser to the folder and follow the directions. You can also read the README.TXT file for directions. The script does some tests to make sure things are set up correctly, going so far as to insist that you password protect your directory. You can disable this check in the script directly, but you should probably do this to at least keep casual visitors from nosing around the sensitive parts of your server.

» Download error_log.zip

Related Links

Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Email Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Facebook Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Twitter Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Google+ Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Delicious Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Digg Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on reddit Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on StumbleUpon Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Wordpress Share 'Separate PHP Error Logs for Multiple Domains with Plesk' on Instapaper
Posted in Computers and tagged . Bookmark the permalink.

4 Responses to Separate PHP Error Logs for Multiple Domains with Plesk

  1. jlacivita says:

    Is there a similar configuration change you can make for the apache logs?  I’ve read elsewhere that media temple merges all of your sites stats together.

    I’m considering getting their (dv) service, but all the (gs) complaints i’ve read online gave me pause (even though its a different plan).  Your site is making me consider it again.

    ——-

  2. Dave Seah says:

    I think that actually the server logs are separated already. Looking at the Plesk control panel, every domain name has its own log. Subdomains, though, have their data stuck all in the main log file.

    The (dv) plan is pretty stable for me right now, though every few weeks it seems that there’s a giant data clog somewhere in California for a few hours. I did have a bizarre out of memory problem recently that I couldn’t identify.

    I can’t speak for the (gs) plan. People have also been suggesting SliceHost to me as another place to get a reasonably-priced virtual server, so you might check them out too.

  3. There is also a script I found on the internet called logdigester.php for online viewing of php error logs. It will do most recent entries as well as sort between errors, warnings,notices etc. and count duplicates.

  4. Fabien says:

    Hello

    I’m beginning with Plesk
    I have no idea where to find the original PHP log error on my server :-S

    Will I get a (new) file named “error_log” at the root of my website if I create a “vhost.conf” file with :

    “php_value error_log /var/www/vhosts/mywebsite.com/httpdocs
    …”

    Thank you

    Fabien