Every installation of PHP comes with default settings which are usually fine for most websites. Occasionally, the needs of a website makes it necessary to adjust these PHP settings. To view any PHP errors or warnings that could result, you can view your error.log file:
You can also create your own PHP error.log file to store these errors in a different location.
Creating your own custom PHP error.log file will override the default location of your error.log file. When you create the file as shown below, you will no longer see future PHP errors/warnings in your error.log file. You will only see future PHP errors/warnings within your custom PHP error.log file.
However, this only applies to PHP errors. Any other website errors such as Apache webserver errors will continue to show in your regular error.log file.
The standard term for a PHP configuration file is php.ini. However, DreamHost uses the term "phprc" file instead. This acts the same way – only the name is different. In this article, only the term phprc is used.
By default, DreamHost logs PHP errors in your domain's error.log file, but you can change the PHP error logging location using a phprc file. Changing the location of PHP error logging is a simple step that allows custom access to PHP errors to diagnose problems with your website.
View the following articles for instructions on how to create a phprc file.
If the file already exists, view the following articles for instructions on how to update it (depending on if you're using an FTP client or SSH):
Add these lines to your phprc file:
log_errors = 1
error_log = /home/username/php.log
Replace username with your SHELL user.
Kill off all running php processes
Make sure to kill running php processes to ensure your new settings take effect.
Confirming your changes
After you've edited the file and killed off all PHP processes, you should check to confirm the values have updated. You can do this by creating a phpinfo.php file.
If you do not see your changes have updated, try killing off your PHP processes again:
Testing the php.log file
To test the php.log file, create a PHP file that throws an error. For example, create a file named error.php with the following content and upload it to your site.
<?php $file=fopen("welcome.txt","r"); ?>
Visit the example.com/error.php page in a browser. An error is thrown. If you then check your user's home directory, you'll see the php.log file has been created and that it logged this PHP error. Run the following to check it:
[server]$ cat $HOME/php.log
At first, the new php.log file will not exist. Only after a PHP error is thrown is the php.log file automatically created. This file will then continue to log any future PHP errors.