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. For example, your site may show errors and not responding as it should. In that case, you could create a php.ini (phprc) file to turn on PHP error logging which may help to identify the issue.
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 does not log PHP errors, but you can enable PHP error logging through your phprc file. Enabling PHP error logging is a simple step that allows easier diagnosis of 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.