Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
PHP ›
PHP error_log .htaccess

PHP error_log .htaccess

January 17, 2011 PHP Jesin A 1 Comment

php category thumbnail

The PHP error_log setting specifies in which file the PHP script errors are logged. This setting is usually specified in the PHP configuration file php.ini which points to a file in which errors of all PHP scripts on that server are logged. It can be modified per directory basis to maintain separate logs for different set of scripts. For users on shared hosting account it is a bonus feature of being able to modify the error_log setting. Normally the error log is a single file for an entire server which is stored in one central place which is only accessible by the root user. But by modifying the error_log setting using htaccess you can have a separate error log for your web hosting account. The php_value error_log requires the php_flag log_errors to be On.

Set PHP error_log value in .htaccess

Go to your document root (www or public_html or htdocs folder) and create a file name.htaccess if it already exists edit it. First the log_errors flag should be turned on then the error_log should be set. The error_log file should be an absolute path e.g. /home/username/php_errors.log. Add the following to your .htaccess file.
php_flag log_errors On
php_value error_log "/home/username/php_errors.log"

It is recommended to have the log file outside the document root so that it is not viewable by the public. Save the file, create a PHP file with errors and test it.

Related posts:

Default ThumbnailDisabling PHP Display Errors php category thumbnailHow to use custom php.ini files on shared hosting php category thumbnailHow to use PHP to minify HTML output Default ThumbnailRedirect http to https using htaccess Default ThumbnailSetting a Timezone in PHP

Tags: htaccess, php

Trackbacks

  1. Fix the client intended to send too large body nginx error | Jesin's Blog says:
    March 19, 2013 at 3:49 pm

    […] max_upload_filesize directives, but modifying them did not solve the problem. Taking a look at the PHP error log I couldn’t find anything helpful. Finally I saw nginx’s error log which contained this […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.