I have a website with multiple pages that I uploaded onto the Ligtsail Bitnami LAMP server using FileZilla.
The .HTML pages work fine. The .HTML pages that use jQuery to GET or POST php work fine.
The .php pages that contain HTML or are simply PHP do NOT work at ALL. When I go into inspector to see what is wrong, none of the HTML or JS that is contained in the .php files is shown, instead this is all that is displayed in the inspector:
<html>
<head></head> == $0
<body></body> == $0
<html>
And the following error is displayed:
"filename.php:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)"
When tested on localhost using XAMPP, all files work. I am new to servers and I hope this is just a newbie issue, let me know if there is any other information I can include.
I checked the /opt/bitnami/apache2/logs/error_log and these are my errors:
PageSpeed Serf fetch failure rate extremely high; only 1 of 21
recent fetches fully successful; is fetching working?
localhost: server certificate does NOT include an ID which matches the server name
Bitnami Engineer here,
The Bitnami LAMP solution in the Lightsail platform comes with Apache and PHP preconfigured for you to use. From your message, you are getting a 500 error message. I understand there is something wrong in the PHP code you are trying to load and that's why that 500 error occurs. Can you try to create a simple "Hello World" page with PHP in the /opt/bitnami/apache2/htdocs folder and see if everything works as expected
<?php
echo '<p>Hello World</p>';
?>
If you get the Hello World message when accessing yoursite/file.php, that means that PHP is working properly. If you keep getting errors, you can take a look at the Apache's log file (/opt/bitnami/apache2/logs/error_log) to get more information about them
https://docs.bitnami.com/aws/infrastructure/lamp/troubleshooting/debug-errors-apache/
Please help me, my server is crashed, for static files it's fine, but my server throws error 502 bad gateway for every php script run from browser. I created a simple test.php script, when I run this scrip from command line using php test.php it's working, but when I try to open it from my web address mydomainname(dot)com/test.php or ip_address/test.php it got 502 bad gateway.
Please help me or give me some suggestions about what to check. I'm so confused because everything looks normal here. I'm using php 7.3 and Ubuntu 16.04 by the way
PHP works because you call it directly with PHP text.php
When you try to open a page with a browser, you need a web server. Something like Apache or Nginx. You have an error because you are error on your web server configuration.
Check the log of web server to find out the problem.
I am having an issue when I have a php application that is returning an internal server error (500) however nothing is showing up in the error log.
Now I know there are error with what I am trying to run, I know I have missing some files and what not but something should show in the apache error log (otherwise how are I supposed to know exactly what I am missing).
I created a test script is errors it in under the same vhost configuration and those error show up fine so everything seems configured right as far as php/apache. Are there certain php errors that does show up in the error log (php is configure to display any type of notice, warning, , error, fatal error, etc...)?
This is running on ubunut 10.04 with the standard apache and php from the ubuntu repo with apt-get.
Scan your source files to find #.
From php documentation site
Currently the "#" error-control operator prefix will even disable
error reporting for critical errors that will terminate script
execution. Among other things, this means that if you use "#" to
suppress errors from a certain function and either it isn't available
or has been mistyped, the script will die right there with no
indication as to why.
Copy and paste the following into a new .htaccess file and place it on your website's root folder :
php_flag display_errors on
php_flag display_startup_errors on
Errors will be shown directly in your page.
That's the best way to debug quickly but don't use it for long time because it could be a security breach.
If you still have 500 error and no logs you can try to execute from command line:
php -f file.php
it will not work exactly like in a browser (from server) but if there is syntax error in your code, you will see error message in console.
Maybe something turns off error output. (I understand that you are trying to say that other scripts properly output their errors to the errorlog?)
You could start debugging the script by determining where it exits the script (start by adding a echo 1; exit; to the first line of the script and checking whether the browser outputs 1 and then move that line down).
In the past, I had no error logs in two cases:
The user under which Apache was running had no permissions to modify php_error_log file.
Error 500 occurred because of bad configuration of .htaccess, for example wrong rewrite module settings. In this situation errors are logged to Apache error_log file.
For Symfony projects, be sure to check files in the project'es app/logs
More details available on this post :
How to debug 500 Error in Symfony 2
Btw, other frameworks or CMS share this kind of behaviour.
Here is another reason why errors might not be visible:
I had the same issue. In my case, I had copied the source from a production environment. Hence the ENVIRONMENT variable defined in index.php was set to 'production'. This caused error_reporting to be set to 0 (no logging). Just set it to 'development' and you should start seeing error messages in apache log.
Turned out the 500 was due to a semi colon missing in database config :-)
Another case which happened to me, is I did a CURL to some of my pages, and got internal server error and nothing was in the apache logs, even when I enabled all error reporting.
My problem was that in the CURL I set
curl_setopt($CR, CURLOPT_FAILONERROR, true);
Which then didn't show me my error, though there was one, this happened because the error was on a framework level and not a PHP one, so it didn't appear in the logs.
You need to enable the PHP error log.
This is due to some random glitch in the web server when you have a php error, it throws a 500 internal error (i have the same issue).
If you look in the PHP error log, you should find your solution.
see here in the doc of how to enable it in the php.ini
Be sure your file permissions are correct. If apache doesn't have permission to read the file then it can't write to the log.
What happened for me when this was an issue, was that the site had used too much memory, so I'm guessing that it couldn't write to an error log or displayed the error. For clarity, it was a Wordpress site that did this. Upping the memory limit on the server showed the site again.
SOLVED
I struggled with this and later on, I realized that I was working on PHP 5.6, so I upgraded to PHP 7.0, then I released there were comments placed by git for conflicting codes. I found something like this in my code <<<<<<<< But solved it.
I have a web application programmed in php hosted on windows server which was working great until recently he encountered "http 500 internal server error" only on 1 php page which was basically retrieving and displaying information from database. i checked to see what can be the possible reasons for that error to happen. when i tried to generate the same error after including ini_set('display_errors', 1); in that php page, the page started working.
and I dont know what was the reason which was causing that http 500 error to generate.
if anyone has idea about this issue then please share the knowledge, it would be great help.
Check the php_error.log, if you do not know the location, open php.ini and find the path, or enable it if not enabled. Then log the error.
So I have a website built in php and it was working perfectly on one server, I then moved the website to a server I have on Digital Ocean and am running into several errors, they seem to be based around http request failures while using the imagick library...
I was hoping to not to have to start debugging this from a code point of view as it was already working perfectly and would prefer to change server settings.
Fatal error: Uncaught exception 'ImagickException' with message 'Imagick::__construct(): HTTP request failed! HTTP/1.1 404 Not Found .
I cannot figure out what differences there, on both server allow_url_fopen is set to on.
The php version is different, 5.520 on the original server, 5.5.9 on the new server.
The versions of imagick are the same. I am also getting some other errors using the mpdf library but I will try deal with these later (Im hoping if I can resolved the first ones these ones will also get resolved).
My question is , is there possibly any other setting on the server I should be looking out for that may be causing these php errors?
EDIT:
Just to add more information, i can get rid of some of the errors by changing the file path https://www.example.com/myimage.jpg to /var/www/example/myimage.jpg . This solves some of the errors but I would rather get the root of the issue thats causing it not to work in the first place, because I feel that its the same problem thats causing other errors.
The error code says it: 404, file not found. You are probably using the wrong URL.
Are you able to fetch https://www.example.com/myimage.jpg using a webbrowser?
On several popular linux distros, /var/www/example/myimage.jpg would be served at https://www.example.com/example/myimage.jpg instead of https://www.example.com/myimage.jpg with the default configuration.
[edit]
It just came to my attention that the URL is HTTPS, there is a possibility that the script is rejecting the server certificate. Try with regular HTTP - no point in using SSL if the file is on the same machine.