Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Fixing "Internal Server Error" (500) in Apache/Nginx

3 min read
10.08.2025

Check Server Logs for More Details

The first step in diagnosing the issue is checking the error logs.

500 Internal Server Error Fix
500 — read the error log; the cause is always there.

For related server-error topics, see Error 508 — Resource Limit Reached, Increasing PHP Limits, and Fixing ERR_INVALID_RESPONSE in PHP.

Apache Error Log

sudo tail -f /var/log/apache2/error.log  # Debian/Ubuntu
sudo tail -f /var/log/httpd/error_log    # CentOS/RHEL

Nginx Error Log

sudo tail -f /var/log/nginx/error.log

Identify the specific cause of the error before proceeding with fixes.

Fix .htaccess Issues (For Apache)

A corrupted .htaccess file is one of the most common causes of 500 Internal Server Errors.

Rename .htaccess to Disable It

mv /home/user/public_html/.htaccess /home/user/public_html/.htaccess_backup

Restart Apache

sudo systemctl restart apache2

Regenerate .htaccess (For WordPress)

If your site is WordPress-based:

  • Go to WordPress Admin > Settings > Permalinks
  • Click Save Changes to regenerate .htaccess.
  • If the issue is resolved, update .htaccess manually and check for syntax errors.

Check PHP Configuration & Errors

If the error is PHP-related, check the PHP logs.

Enable Debugging in wp-config.php (For WordPress)

Edit the wp-config.php file:

nano /home/user/public_html/wp-config.php

Add or update:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

Error logs will be stored in wp-content/debug.log.

Check PHP Error Logs

For Apache:

sudo tail -f /var/log/apache2/php_errors.log

For PHP-FPM:

sudo tail -f /var/log/php8.0-fpm.log

Fix any PHP syntax errors or missing extensions.

Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

Check File & Folder Permissions

Incorrect permissions can prevent the server from accessing files.

Set Correct File & Directory Permissions

find /home/user/public_html -type d -exec chmod 755 {} \;
find /home/user/public_html -type f -exec chmod 644 {} \;

Set Correct Ownership

For Apache:

chown -R www-data:www-data /home/user/public_html

For Nginx:

chown -R nginx:nginx /home/user/public_html

Restart the web server after applying changes:

sudo systemctl restart apache2
sudo systemctl restart nginx

Increase PHP Limits

If your site requires more memory, increase PHP limits.

Edit php.ini

sudo nano /etc/php/8.0/apache2/php.ini  # Apache
sudo nano /etc/php/8.0/fpm/php.ini      # Nginx

Modify the Following Settings

memory_limit = 512M
max_execution_time = 300
upload_max_filesize = 128M
post_max_size = 128M

Restart PHP & Web Server

sudo systemctl restart php8.0-fpm
sudo systemctl restart apache2

Fix Server Configuration (Apache/Nginx)

If the error persists, the issue may be with the web server configuration.

Check Apache Config for Syntax Errors

sudo apachectl configtest

If errors appear, fix them in:

sudo nano /etc/apache2/apache2.conf

Restart Apache:

sudo systemctl restart apache2

Check Nginx Config for Syntax Errors

sudo nginx -t

If errors appear, edit:

sudo nano /etc/nginx/nginx.conf

Restart Nginx:

sudo systemctl restart nginx

Summary of Fixes

Issue Fix
Corrupt .htaccess file Rename it & regenerate via WordPress
PHP errors Enable debugging in wp-config.php & check logs
File/folder permission issues Run chmod 755 for directories, chmod 644 for files
Memory limits exceeded Increase memory_limit in php.ini
Apache/Nginx misconfiguration Run apachectl configtest or nginx -t

Now your website should work without an Internal Server Error!

Frequently asked questions
Apache: `/var/log/apache2/error.log` (Debian/Ubuntu) or `/var/log/httpd/error_log` (RHEL). Nginx: `/var/log/nginx/error.log`. Per-vhost: may be in `/var/log/apache2/` or `/var/log/nginx/sites/`. cPanel: `/usr/local/apache/logs/error_log` plus `/home//logs/`. Always tail -f the log while reproducing the 500 — the relevant line appears at exactly that moment.
Just-edited .htaccess with a syntax error. Apache loads .htaccess per request; an invalid directive = 500 immediately. Test: rename .htaccess to .htaccess.bak; if 500 goes away, found it. Restore minimal contents and add lines back one at a time until 500 returns — the last addition is the bug.
Server-side update: PHP version, Apache module, OS patch. Or disk filled, or memory exhausted (OOM killer killed PHP-FPM). Check system status: `df -h` for disk, `free -m` for RAM, `journalctl -p err -S today` for system errors. Hosting provider may have applied an update that broke compatibility — check status page.
Enable `display_errors = On` in php.ini briefly. Reload page — fatal now shows inline. Find and fix. Re-disable display_errors after. Don't leave display_errors on production — leaks internal paths. For ongoing production diagnosis, rely on `log_errors = On` and read error_log.
Related articles
Debugging session_start() Errors in PHP Using Error Logs
Fixing "A Fatal Error or Timeout Occurred While Processing This Directive"
Fixing "A Fatal Error or Timeout Occurred" by Increasing PHP Limits