Question

Getting 500 Errors (Internal Server && || HTTP Error ) on Droplet

Hi There!

I recently migrated files and DB from a really old droplet to a new LAMP 1-click install droplet. I installed a Let’s Encrypt SSL cert and the site is resolving at its domain clients.nevilleco.com. The issue I’m having is that any PHP-generated pages are throwing a 500 error. It seems like it may be both internal server errors (apache) and HTTP errors (PHP).

If you click on ‘Client Services’ in the left-hand menu you’ll see an internal server error 500 logged in the console. If you click on the Newsroom and then Press Releases it seems like you get an HTTP 500 error (at least according the Chrome).

I’ve gone through a number of posts in the community about this issue and I’ve run the CHOWN command to set Apache as owner of the site files as described here https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress and still no dice.

Running tail -50 /var/log/apache2/error.log gives me

[Wed Jun 17 06:25:15.958469 2020] [mpm_prefork:notice] [pid 1585] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Wed Jun 17 06:25:15.958554 2020] [core:notice] [pid 1585] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 17 11:48:15.708434 2020] [:error] [pid 19792] [client 195.54.160.135:49592] script '/var/www/html/www.nevilleco.com/index.php' not found or unable to stat

And the access.log tail -50 shows this:

https://gist.github.com/AndrewSepic/a4a2b412de3407bd1aaf87036876eb9f

My virtual hosts file 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 17, 2023

Hi there,

According to the error that you’ve shared the path to the index.php file is not correct.

You need to make sure that the document root of your website is actually in the /var/www/html/www.nevilleco.com directory. You can use the ls command to verify this:

ls -lah /var/www/html/www.nevilleco.com

If this is not the case, there are a few things that I could suggest:

  1. Check PHP Version Compatibility: Ensure that the PHP version on your new server is compatible with the version your site was built on. PHP code that was working fine on an older version may break on a newer one.

  2. Inspect PHP Error Logs: Review your PHP error logs for any specific messages related to the 500 errors. These logs may provide more insight into what’s causing the problem. You can generally find them at /var/log/php7.x-fpm.log or similar, depending on the PHP version.

  3. Review Apache Configuration: From the error message, it appears that the script at /var/www/html/www.nevilleco.com/index.php is not found or unable to stat. Make sure that the path is correct and the file has proper permissions.

  4. Fix Ownership and Permissions: It might be an ownership or permissions issue. Try running:

    sudo chown -R www-data:www-data /var/www/html/www.nevilleco.com
    sudo find /var/www/html/www.nevilleco.com -type d -exec chmod 755 {} \;
    sudo find /var/www/html/www.nevilleco.com -type f -exec chmod 644 {} \;
    
  5. Check .htaccess Rules: If you’re using .htaccess files for URL rewriting or other directives, make sure the rules are correct and compatible with your current Apache version.

  6. Disable/Enable Modules: Try disabling/enabling certain Apache or PHP modules that might conflict with your configuration.

  7. Verify Virtual Host Configuration: Your virtual host configuration seems fine, but ensure that the document root is correct and that the paths to the SSL certificates are accurate.

  8. Restart Services: After making changes, don’t forget to restart Apache and PHP-FPM (if used):

    sudo systemctl restart apache2
    sudo systemctl restart php7.x-fpm
    

Hope that this helps!

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

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