I'm having an issue where I get an "Internal Server Error" on my php page. To try and debug it, I attempted to use the error_log function in php. However I could not get it to write anything to the error log. Even in a simple php file:
httpdocs/temp.php
<?php
error_log("this is an error");
echo "hello";
?>
I would receive a basic internal server error message:
Internal Server Error The server encountered an internal error or
misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the
error occurred and of anything you might have done that may have
caused the error.
More information about this error may be available in the server error
log.
Web Server at xxxxxxxx.com
So I looked up how to set up the error_log properly, thinking that it was somehow not set up correctly. I found this article.
Since I am on windows I edited the .user.ini file in my httpdocs root folder and added the error_log line:
httpdocs/.user.ini
[PHP]
error_log=G:\PleskVhosts\xxxxxxxxxx.com\httpdocs\php_error.log
display_errors=off
log_errors=on
open_basedir="G:/PleskVhosts//xxxxxxxxx.com\;C:\Windows\Temp\"
safe_mode=off
sendmail_from=xxxxxxxxx#xxxxxxxxx.shr.prod.phx3.secureserver.net
SMTP=relay-hosting.secureserver.net
This article helped me get the absolute path
I restarted the IIS application pool and created an empty php_error.log file in my httpdocs folder, however it still never wrote anything to the log file, and continued to just give the Internal Server Error. I also tried removing all the other lines in the .user.ini file besides the error_log line, restarted, and still nothing. I also tried stopping the application pool and starting it up again, still nothing.
I double checked the phpinfo and the log_errors field was set to on, and the correct directory was set for error_log. So it is seeing the .user.ini file.
I tried calling their support but they couldn't help me.
They linked me to this article about IIS error handling. I created a web.config file and put it in the httpdocs folder as it says in that article. Now I get something different. Now the output of my page is the error that I was passing to error_log. So in other words, when I visit test.php the output on the screen says:
this is an error
Notice how the php script dies after the error? Not only should the error not be put on screen (it should be put in the php_error.log file, which is still not being written to at this point), but the php script shouldn't die afterwards unless it runs into a fatal error. I should see the "hello" from the echo and I don't.
What do I have to do to get this working properly?
My hosting plan has IIS 8 and PHP 5.4 installed.
PS. Their support basically said they cant help me any further because changing configuration files is "coding" and they dont offer coding support.
PHP needed file read write permisions
Related
Recently, I put my project which is php+smarty+mysql in my httpd server. But I encountered an error that says:
500 Internal Server Error
My OS is archlinux, and the httpd server and php were installed like this:
sudo pacman -S apache php
If I use a test native php file which contains the following:
<html>
<head>
<title>PHP Test Page</title>
</head>
<body>
This is Arch Linux, running PHP.
<?php
phpinfo();
?>
</body>
</html>
it runs correctly. It tells me that the php can work well. But why is my project with smarty not working? Is there any one who has encountered this problem?
With the info you provided it's difficult to say.
Error 500 happens because you did some error in the code that is supposed to produce the page, or the code generates some unhandled exception.
My suggestion is to visit the page that gives you the 500 error, and then try to comment out all your code. See if the issue is still present. If not, uncomment the code until you find the critical part that originates the error. Could be anything, a typo, a file not found, a logical error, anything.
Also, check in the webserver logs, if you can read them.
Look in your Apache error log (often found at /var/log/httpd/error_log, though this varies greatly). It will have more information about the server error.
Check to make sure that any .htaccess files are correct (syntax wise).
just happened to me and wanted to write down the solution.
The configured Smarty cache directory (/var/cache/Smarty) was configured with incorrect permissions, the apache process needs to create files in that directory.
This is the directory you set with the compile_dir directive.
BTW, the error_log file doesn't show anything with this error, Firebug shows a 500 Internal Server Error.
I was able to get the error details by checking error.log file inside
/var/log/apache2
in ubuntu 16.04
I've hosted websites with companies like hostgator before where if a PHP error was thrown it would write to a file in the directory of the site where the error was made. The file would be called error.log or something like that.
I would like to set this up on my local machine, does anyone know if this possible with an out of the box setup of XAMPP?
PHP Runtime Configuration
log_errors boolean.
Tells whether script error messages should be logged to the server's error log or error_log. This option is thus server-specific.
You can probably find the php.ini in the php subfolder of the xampp installation.
first I wish you a happy new year!
I got the following problem:
I receive an Internal Error 500 when trying to open one of my websites on my server which uses .php files. All Domains configured on this user don't work. The Domains configured on other users are working fine.
Checking out the error log gave me the error "Premature end of script". Until yesterday everything worked fine and I haven't made changes since than.
I checked out the following possibilities:
APC in php.ini -> doesn't exists in my php ini (https://www.drupal.org/node/213260)
File Permissions (500 Server error: Premature end of script headers:)
RLimitCPU and RLimitMEM
some other things with general configuration, but they can't be the reason because my other sites with php are working fine
I compared the Apache config of the different domains but couldn't find a relevant difference. Unluckily I changed the rights of the files in this directory and now my ftp isn't working anymore (set them to 705). Any Ideas on both problems?
Server is CentOS 6.7 with PHP 5.3.3 and Webmin Interface
FTP Server is ProFTPD
Thanks in advance!
I solved the problem with the premature end of script. The quota of the user was more than full, which was done by a failure in a cronjob. facepalm
I recently uploaded a website for a friend in byethost just for viewing purposes. When I tried to check if it is working, all HTML pages are working correctly but when I access php pages a server error 500 occurs. What can be the problem?
I have checked for a .htaccess files as many forums here suggests but to no avail since my account does not have that page. It only occurs when I alter php configuration in the cpanel which suggests to put magic quotes 'on' or 'off' but after, the php page displays no server error but it displays a blank.
I had edited the connection php page to "# mysql...." Instead of "mysqli" can this be the reason? And can anyone help me with this problem?
You need some debugging.
In your php file:
ini_set('display_errors', 1);
In .htaccess file:
php_flag display_errors 1
Also, you might want to check this out: Getting Internal Server Error while trying to access my site
Recently, I put my project which is php+smarty+mysql in my httpd server. But I encountered an error that says:
500 Internal Server Error
My OS is archlinux, and the httpd server and php were installed like this:
sudo pacman -S apache php
If I use a test native php file which contains the following:
<html>
<head>
<title>PHP Test Page</title>
</head>
<body>
This is Arch Linux, running PHP.
<?php
phpinfo();
?>
</body>
</html>
it runs correctly. It tells me that the php can work well. But why is my project with smarty not working? Is there any one who has encountered this problem?
With the info you provided it's difficult to say.
Error 500 happens because you did some error in the code that is supposed to produce the page, or the code generates some unhandled exception.
My suggestion is to visit the page that gives you the 500 error, and then try to comment out all your code. See if the issue is still present. If not, uncomment the code until you find the critical part that originates the error. Could be anything, a typo, a file not found, a logical error, anything.
Also, check in the webserver logs, if you can read them.
Look in your Apache error log (often found at /var/log/httpd/error_log, though this varies greatly). It will have more information about the server error.
Check to make sure that any .htaccess files are correct (syntax wise).
just happened to me and wanted to write down the solution.
The configured Smarty cache directory (/var/cache/Smarty) was configured with incorrect permissions, the apache process needs to create files in that directory.
This is the directory you set with the compile_dir directive.
BTW, the error_log file doesn't show anything with this error, Firebug shows a 500 Internal Server Error.
I was able to get the error details by checking error.log file inside
/var/log/apache2
in ubuntu 16.04