MediumWordPress Debugging On Apache (500 Internal Server Error) | by Taha HAKKOU | Medium
Sitemap

WordPress Debugging On Apache (500 Internal Server Error)

3 min readApr 14, 2024

--

Press enter or click to view image in full size

Issue Summary

On April 09 , 2024, a broken Ubuntu 14.04.5 LTS container was released as a debugging challenge for the ALX software engineering curriculum. When sending GET requests to the Apache web server running on the container, that responds with a500 Internal Server Error, when the expected response was an HTML file defining a ‘Holberton’ WordPress site.

All students were working for 3 days long (from April 9th to April 11th) to resolve that error. The root cause of this issue was a typographical error in the /var/www/html/wp-settings.php file showed in the following line. Where the extension phpp should it be php instead

Get Taha HAKKOU’s stories in your inbox

Join Medium for free to get updates from this writer.

require_once(ABSPATH . WPINC . '/class-wp-locale.phpp' );

Timeline

from a student perspective:

  • Apache web server is returning a 500 Internal Server Error instead of an HTML file defining a ‘Holberton’ WordPress site when tried to curl 127.0.0.1

The challenge recommanded using tmux & strace in the debugging process:

  • The student checked running processes using ps auxf. Three apache2 processes - root and 2 www-data - were properly running.
  • The student decide to use strace. In one terminal, ran strace on the PID of the root Apache process. In another, curled the server. But strace did not give a useful information.
  • He run strace again, but this time he decided to try a child process of apache2 using the PID of the www-data process. And checked the result of strace.
  • Finally, strace revealed an -1 ENOENT (No such file or directory) error occurring upon an attempt to access the file /var/www/html/wp-includes/class-wp-locale.phpp
lstat("/var/www/html/wp-includes/class-wp-locale.phpp", 0x????????????) = -1 ENOENT (No such file or directory)
  • He starts a search to find out which file contains the typo error running grep -nr '.phpp' /var/www/html/and he found that the filewp-settings.php contains the error
wp-settings.php:require_once( ABSPATH . WPINC . '/class-wp-locale.phpp' );
  • The student fixed the error deleting the extra p from the line of the file wp-settings.php
  • He tested another curl on the server. and Great News a 200 response!

Root cause:

The root cause was a typographical error in wp-settings.php wordpress app file, when trying to load the file class-wp-locale.phpp. The correct file extension was .php. This let the server to send a 500 internal error.

Resolution

A simple typo fix, removing the trailing p. The solution was also automated using a puppet script if such error occurs in other servers.

Prevention

This outage was an application error and not a web server error. In order to prevent such outages moving forward:

  • Testing the application before deployment: This error would have arisen and could have been addressed earlier if the app has been tested before deploying it.
  • Uptime monitoring: Having a monitoring tool which should be attached to each of the web-servers to alert instantly upon outage of the website.

--

--