Blog

Why are you getting 500 internal server error on your php pages

Tags: 500 ISELinuxSecuritysuPHP

Published on: April 22, 2009 by George K.

Why are you getting 500 internal server error on your php pages

Scenario:

Linux server management is all about finding out solutions to various issues arising on Linux servers, I am giving an example that, some clients have come across the issue that they are getting 500 internal error on all their PHP pages. Usually, this happens in a suPHP environment. There could be few reasons why this could happen. We list here a few. The solution is intended for those with shell access.

  • Ownership issues
    In a suPHP environment, depending on the mode of suPHP enabled on the VPS or server, there is a min_uid setting, which is configurable in suPHP.conf under /etc or /usr/local/etc or /opt/suphp/etc . By default the setting is 100, which means if the file is owned by a UID less than that value (100), it shouldn’t parse the php code and will result in 500 Internal Server Error. In a cPanel server, the error will be shown @ /usr/local/apache/logs/suphp.log. This restriction would enable better security, since even if a php can do some privilege escalation, it wont affect the server. Solution would be

    chown your_username.your_username path_of_your_php_file

    If that fixes only that file and not your entire php files, use the below command to change all the php files.

    find . -type f -name “*.php” -exec chown username.username {} \;
    find . -type d -exec chown username.username {} \;

    Ignore “*.php” in the above command if it still errors out for a php file. If it still don’t fix, move on to other solutions below.

  • Permission issues
    It could be the world writable directories or files which is causing the issue. In a non-suphp environment, if a php script has to upload a file on a folder, (eg:  php based gallery script where customers are able to upload photos) inorder to get it uploaded to the folder, it needs to have world writable permissions. Or else apache can’t write to the folder. Here in suPHP, since the php is executed as the user itself who already have the permissions you don’t need to change it to 777 permissions and is happy with 755 (rwxr-xr-x) permissions. When a customer is moved from a non suPHP env to suPHP enabled server, we need to adjust the permissions then. Often a command like below should help

    find . -name “*.php” -type f -exec chmod 644 {} \;
    find . -type d -exec chmod 755 {} \;

    Often, you can do the above command without the -name “*.php” in the command.

  • suphp.log exceeds 2GB size.If the entire servers’ php application gives you internal server error, next chance is that the suPHP log has exceeded 2GB space. Just clear the file and you are on track again. To null it, execute the command below. Below command assumes you are having the issue in a cPanel server

    cat /dev/null > /usr/local/apache/logs/error_log

  • suPHP log don’t exist
    In a Plesk or Webmin or other servers, often the suPHP will be installed but /var/log/httpd or such folders where the suPHP.log can be created wont exist. suphp can understand and create a non-existent suphp.log, but you would need to manually create the folder /var/log/httpd. I hope you know how to create a folder though.
  • If you know any other cases which require another solution for this, please comment here or edit the blog.

If you need any assistance regarding linux servers do contact our Linux server management team

Category : cPanel, Linux, Plesk

George K.

George K.

George started his career in web hosting and Linux technical support in the year 2004 and is with SupportSages since 2009. He has keen interest in server optimizations, custom security solutions, hacked server recovery, cyber forensic and high availability fail over system design and implementation. George loves long drives and is passionate about art and literature.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Categories

Your Cart

Cart is empty.

Subtotal
₹0.00
APPLY
0
Send this to a friend