0

There is a folder on my apache server containing several php scripts. All the php scripts in this folder work except for 1. All the php scripts including the script that doesn't work have the same rights.

When I run the script in my browser I get this error:

HTTP ERROR 500

Details that may be helpful:

PHP Version 7.0.11 Apache/2.2.15 (CentOS)

15
  • what's in the (error) logs? Commented Sep 29, 2016 at 17:03
  • Details that may be helpful: the code from the script that blows your server up!!! PHP Code can be written so badly that it can cause 500 errors Commented Sep 29, 2016 at 17:06
  • Its not just about rights, even a syntax error can generate that error on a lot of setups Commented Sep 29, 2016 at 17:06
  • 1
    @Fred-ii- I tried removing ?> at the end and also added exit; right at the start of the script, but both didn't work. However, if I delete all the code and then echo 'HELLO'; the script works. It is just a matter of building the code up piece by piece to track down the exact problem. Commented Sep 29, 2016 at 18:05
  • 1
    @BastiaanWW That's what I was going to suggest earlier, that you place breaks here and there to see where it starts to break by removing them one at a time. It's a lenghty process, but it gets the job done. Commented Sep 29, 2016 at 18:06

2 Answers 2

1

An Apache status code of 500 means "internal server error". Without seeing the code that is producing this error it is hard to say what is causing it but the first things to check are server configuration and your .htaccess file. Make sure your server is running properly then check your .htaccess file as a bad rule can force some types of PHP to malfunction. As @RiggsFolly stated, it is also possible that the problem is some very poorly written PHP which can be tested by replacing it with a simple program like: <?php echo "test"; ?>

Sign up to request clarification or add additional context in comments.

Comments

0

SOLUTION: In my case the problem of 500 error was the upgrade from php 5.x to 7; BUT: I imagine this error can come from many other reasons, so if it does not apply, good luck finding the other solutions. In this case, it worked - and the solution is to rewrite the code or downgrade to old PHP version until you re-code the incompatible parts.

EXPLANATION / DEBUGGING PROCESS: After several tests to identify what is happening (commenting parts of code, testing functions, reading documentation), I found that deprecated functions from previous versions of PHP will generate a 500 Error.

For example, in a script written for PHP<7 you may still have old mysql queryes like mysql_connect, and once your server is updated to 7 (and you must use mysqli), this script will throw 500 error. I imagine this happens to any other function that became deprecated.

In your case, my bet is most of the scripts are compatible with 7, one is not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.