Thu Jun 20 21:43:00 EDT 2024
Home#OpEdAmazon AWS Lightsail Critical Error on WordPress

Amazon AWS Lightsail Critical Error on WordPress

Access Amazon AWS WordPress from Command Line

About 36 hours ago, a well used plugin in the WordPress ecosystem wreaked havoc across the internet. As of January 2024, 8.8 million websites worldwide use Elementor, which is 3.7 million more than in 2022. This includes 3.6 million websites using the Elementor Pro version, and more than 13 million websites built with Elementor. The free Elementor plugin has more than 5 million active installs, and over 260 million overall installs since its launch. To put this better into perspective, WordPress is used by 43.2% of all websites. Among those created with a known CMS, the market share is even higher — 62.8%! So, when an add on to Elementor known as the Elementor Header & Footer Builder had some bad code shipped out, there was a catastrophic failure across the web.

Normally, most folks would simply go into their cPanel — a Linux-based web hosting control panel that provides a dashboard to manage a website or server — and edit the wp-config.php file, set the WP_DEBUG entry to true and track things down. The issue several of my Clients had was that they run their WordPress instances on Amazon AWS Lightsail. The difference between Lightsail and say shared hosting on GoDaddy or TMD Hosting is that you have to understand shell script on a UNIX/Linux operating system. Thus, when they were unable to reach their tech personnel overseas, they reached out to Ghost on Demand. 😉

The dreaded There Has Been a Critical Error on Your Website error was afoot. Many call it the White Screen of Death (WSOD) similar to the Windows Blue Screen of Death (BSOD). With WSOD, though, there is light at the end of the tunnel. The primary coding language used in WordPress is PHP — Hypertext Preprocessor.

Amazon AWS Lightsail is a barebones server that allows for a one click deployment of WordPress. While there was initially a fairly steep learning curve, today it is as simple as plug and play. The challenge with Lightsail is that there is no real graphic user interface (GUI) like with shared hosting or cPanel. Today, we are going to focus on simply getting inside the server, diagnosing the problem, and fixing it.

Triage

After logging into the Lightsail application, you are going to first try a series of actions to simply see if it is an AWS server issue which hung things up or not. Our first level of observation is Triage. First, login to your Lightsail. Then, let’s click the three red dots in the upper right. Then, let’s try to Reboot the system. It may take a few minutes. In another tab, try to reopen your website. If the error is still there, let’s repeat the process, this time selecting Stop. Once the server is stopped, let’s click the three dots again and then select Start. Try to open your website in another tab again. If this didn’t solve the issue, then we are going to move to the operating theater.

Operating Theater

What we learned during triage is that our error is not associated with the Lightsail system. Now, we need to dig in and figure out what the issue is. So, let’s click the Command Line button next to the three red dots. It is going to open up the Bitnami Server Command Line in a pop up window. From the command line you are going to type: cd ~/stack/wordpress/ and hit enter. Then, you are going to type: sudo nano wp-config.php and hit enter. Using your manual cursor from the keyboard, you are going to locate the define( ‘WP_DEBUG’, false ); statement and change the false to true. You will then hit the Ctrl and X keys simultaneously. It will ask if you want to save the file and simply hit Y.

Go to a new tab and reload your website. It will publish a bunch of errors citing file names and line numbers. Here is where the fun starts. Somewhere in the errors it is going to cite a file or plugin. In our case it was this,

An E_COMPILE_ERROR error was caused in line 32 of file /home/grlu3439/public_html/wp-content/plugins/header-footer-elementor/header-footer-elementor.php. Error message: require_once(): Failed opening required ‘/home/grlu3439/public_html/wp-content/plugins/header-footer-elementor/vendor/autoload.php’ (include_path=’.:/opt/alt/php74 /usr/share/pear’)

The key here was the directory structure. We know that the error was kicked from a WordPress plugin called header-footer-elementor. It is an add on to the Elementor plugin. So, we are going to go back to our Bitnami Server pop up window and type clear. We are going to now enter cd. Now, enter cd ~/stack/wordpress/wp-content/plugins followed by dir. It will display the files in the plugins directory. In our case, we are searching for header-footer-elementor. Now, we will enter sudo rm -rf header-footer-elementor. The reality is that you could replace the file we used with any file, but make sure that it is the one that is needed as you could do a lot of damage otherwise. Try reloading your website. It may look a bit different, but if it loads and the error is gone, then we know what the issue is.

If the website loads, you are going to login as the Administrator. You will probably have an error that the plugin we removed has been deactivated from WordPress as there is no longer a folder for it. You will have to do some due diligence on the offending plugin to see if there is an update to correct the error. If so, simply re-install it, clear any cache plugins and you may sign out.

A side note here: If you caught the fact that the PHP was set at 7.4 and not 8.1.x you get a gold star. PHP 7.4 has hit end of life and is causing a lot of problems on many platforms as dev’s attempt to bring their creations into the new dawn of PHP 8.x. We will probably cover that down the road as it is an easy fix!

Now, we need to type cd followed by clear in the Bitnami server pop up. Then, we will reverse the debugging on the website by entering cd ~/stack/wordpress/ in the command line. Now, type sudo nano wp-config.php and define( ‘WP_DEBUG’, true ); statement and change the true to false. You will then simply hit the Ctrl and X keys simultaneously. It will ask if you want to save the file and simply hit Y. Then, reload your website to make sure that the debugging statements are gone. If they are, log out of your Lightsail.

That’s it! Code is Poetry!

Paul Williams
Paul Williamshttps://foreclosurepedia.org
Off Grid Linux Junkie and Always a Friend of Labor!

Appointments

Schedule An Appointment

Advertise With Us

Inspectors

For All Your Eviction And Storage Needs NY/NJ

Followers

26,534FansLike
129,807FollowersFollow
47,098FollowersFollow
14,324SubscribersSubscribe

Most Popular