Question

500 Internal Server Error & HTTP 500 Error on Droplet

Hi DO Community, I’ve migrated files and database from an old droplet into a new LAMP 1-click install and while the site resolves and loads basic HTML pages I’m getting both a 500 Internal Server Error trying to access PHP pages and HTTP 500 errors depending on the pages I’m trying to access.

The site is available at clients.nevilleco.com and clicking on ‘Client Services’ on the left hand menu will give you the 500 internal server error. Clicking through to Newsroom -> Press REleases gives a HTTP 500 error.

I’ve gone through a number of similar posts in the community here which address permissions. I’ve run these chown commands to set permissions

Set Apache as the owner for all the files chown www-data:www-data -R * Set directory permissions find . -type d -exec chmod 755 {} \; Set file permissions find:

-type f -exec chmod 644 {} \;

I’ve also set php.ini to error_reporting = on

Here is my apache error log output when I ran tail -50 /var/log/apache2/error.log:

[Wed Jun 17 06:25:03.589620 2020] [mpm_prefork:notice] [pid 867] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Wed Jun 17 06:25:03.589683 2020] [core:notice] [pid 867] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 17 12:11:06.203456 2020] [php7:error] [pid 20892] [client 195.54.160.135:37812] script '/var/www/html/index.php' not found or unable to stat
[Wed Jun 17 14:11:58.364751 2020] [mpm_prefork:notice] [pid 867] AH00169: caught SIGTERM, shutting down
[Wed Jun 17 14:11:58.467941 2020] [mpm_prefork:notice] [pid 399] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Wed Jun 17 14:11:58.468016 2020] [core:notice] [pid 399] AH00094: Command line: '/usr/sbin/apache2'```

When I look at my access.log I can see both the 500 Internal server and the 500 hTTP errors being logged as shown in the following lines.

```87.204.52.195 - - [17/Jun/2020:14:53:15 +0000] "GET /clients/check.php HTTP/1.1" 500 1520 "http://clients.nevilleco.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0"
68.142.59.19 - - [17/Jun/2020:15:01:43 +0000] "GET /press_releases.php HTTP/1.1" 500 185 "http://clients.nevilleco.com/newsroom.htm" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"

The access log looks like it’s an HTTP 500 error regardless, but in the browser they are shown as distinct (internal server error logged in console).

My virtual hosts mod file at /etc/apache2/sites-available/mydomain.com-le-ssl.conf looks like this…

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin dev@unionstmedia.com
        ServerName clients.nevilleco.com
        ServerAlias www.clients.nevilleco.com
        DocumentRoot /var/www/html/www.nevilleco.com

        <Directory /var/www/html/www.nevilleco.com/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/clients.nevilleco.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/clients.nevilleco.com/privkey.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
        ServerAdmin dev@unionstmedia.com
        ServerName clients.nevilleco.com
        ServerAlias www.clients.nevilleco.com
        DocumentRoot /var/www/html/www.nevilleco.com

        <Directory /var/www/html/www.nevilleco.com/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteCond %{SERVER_NAME} =clients.nevilleco.com [OR]
# RewriteCond %{SERVER_NAME} =www.clients.nevilleco.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>
</IfModule>

Any help would be super appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 6, 2023

Hi there,

The error logs you provided, along with your Apache and virtual host configuration, give some clues about what might be going wrong. Here’s how you can troubleshoot the 500 Internal Server Error:

1. PHP Configuration:

The PHP error log shows a message regarding a script not being found or unable to stat. Make sure the PHP files you’re trying to access are in the correct directory:

script '/var/www/html/index.php' not found or unable to stat
  • Check the paths in your Apache configuration and ensure they correspond to where your PHP files are located.
  • Verify that /var/www/html/www.nevilleco.com is the correct path, and all your PHP files are stored there.

2. Apache Configuration:

Your virtual host file looks generally correct, but there are some areas you could investigate further:

  • Directory Permissions: Verify that Apache has read and execute permissions for the directories containing your PHP files. The permissions you’ve set look appropriate, but it could be helpful to double-check.

  • Apache Error Log: The error log is your friend in these situations. Since you’ve already looked at the last 50 lines, you might want to investigate further back in time, especially around the timestamps of the errors.

3. .htaccess File:

If you have an .htaccess file in your web root, it might be causing issues with URL rewriting or other directives. Check the file for any anomalies or misconfigurations.

4. PHP Error Reporting:

Ensure PHP error reporting is enabled and configured properly. You mentioned setting error_reporting = on in php.ini, but you also need to set the appropriate error reporting level. Consider using:

error_reporting = E_ALL
display_errors = On
log_errors = On

Don’t forget to restart Apache after modifying php.ini:

sudo systemctl restart apache2

5. Check for PHP Dependencies:

Make sure all the required PHP extensions and dependencies are installed. If your application relies on specific extensions, they must be enabled in your PHP configuration.

6. Apache Rewrite Rules:

In your virtual host configuration, the rewrite rules are commented out. If your application expects certain rewrite rules, this might be causing issues. Evaluate whether these rules should be enabled.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel