How to create a PHP Error Log File For the VPS

Occasionally, the VPS will begin to crawl because of errors in the PHP scripts. You need to create a log file which will record the errors so you know what’s going on.

(i) First locate the php.ini file. It will be located in the /etc folder. Download the file and open it in notepad. There is a part dealing with “Error handling and logging”. It is arranged systematically;

(ii) Make sure the “log_errors = On” is enabled by deleting the semi-colon ‘;’ before it;

(iii) Under “Log errors to specified file”, enter the path to the error file as follows:

“error_log = /var/www/vhosts/mysite/httpdocs/error.txt” (change this to your path). Make sure the option is enabled by deleting the semi-colon ‘;’ before it;

(iv) go to the path specified and create a file called error.txt. You can create the file with notepad and use FTP to transfer it to the chosen directory. Chmod the file to make it writeable if it already isn’t.

(iv) Wait for some time to see errors being logged in the error.txt file.

Leave a Reply

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