Inquiries regarding logs in the following format are probably the most common due to json errors related to WordPress.
[Thu Jul 25 13:00:50.367263 2024] [proxy_fcgi:error] [pid 26574:tid 140437025085120] [client xxx.it.is.myIp:50810] AH01071: Got error '; PHP message: PHP Warning: Cannot modify header information - headers already sent in /opt/bitnami/apache/htdocs/MY-WEB-1stDOMAIN-FOLDER/wp-includes/rest-api/class-wp-rest-server.php on line 1831; PHP message: PHP Warning: Cannot modify header information - headers already sent in /opt/bitnami/apache/htdocs/MY-WEB-1stDOMAIN-FOLDER/wp-includes/rest-api/class-wp-rest-server.php on line 1831;
In my case, the error log is related to ‘the Invalid JSON Error'(or ‘Receiving JSON error when trying to upload images’). I already know some general advice for solving this problem. And I tried running it.
For example:
-
Consider plugin conflicts on your WordPress. So I turned off/deactivate all plugins and review them one by one.
-
Consider the unique link of the post on your WordPress setting panel. So I tried changing from a general unique link to a unique link of the post title format(or reverse).
-
Remove whitespace in PHP code. So I tried removing spaces from my custom function files(ex: function.php of theme child). And I even tried manually replacing all WordPress resource files through FTP.
-
Regenerate WordPress .htaccess File. So I regenerated .htaccess by WordPress’ default.
-
and etc…
But it wasn’t resolved. So I thought this was a problem with the web server’s absolute path or redirection. This is because this problem occurred after migrating to the Aws Bitnami server.
As those of you who have used it know, bitnami’s LAMP service currently provides a web root to the ‘/opt/bitnami/apache/htdocs/’ path. It means ‘htdocs’ is of a base web directory for a static ip. And in ‘httpd.conf’ or ‘bitnami.conf’, this default/base directory is received as web http. And then host user can be distributed to multisites’ domain directories through ‘vhost.cof’. (MY-WEB-1stDOMAIN-FOLDER, MY-WEB-2ndDOMAIN-FOLDER, MY-WEB-3rdDOMAIN-FOLDER…)
And between this structure, URLs are processed by intervening in the certificated domain address through ‘ssl.conf’.
So,
-
So, I also reviewed the files that process this domain URL and address several times.
-
Of course, I also applied all permissions for the WordPress directory, in which bitnami engineer suggest. (ex: chown -R bitnami:daemon ‘htdocs’ or ‘MY-WEB-1stDOMAIN-FOLDER’)
However, I cannot eliminate errors that appear in ‘Receiving JSON error when trying to upload images’ or in that error.logs file.
This error usually occurs when editing a WordPress post. This doesn’t happen with every post. It happens on some posts and not on others (I’ve heard it’s an issue related to WordPress’s Gutenberg block editor). However, regardless of Gutenberg, that Json errors occur 100% when uploading images.
There is no problem editing posts, uploading and saving images. That error just pops up.
Some recommend the classic editor plugin of WordPress, but I don’t want to deal with this problem that way.
I can’t help but think that it is a design flaw of Editor in WordPress(or bitnami?) that the error does not go away even after various reviews and actions. what do you think? (Is there a way to solve this problem by adjusting/changing Bitnami’s path?)
Please note, I did not use the (multi) WordPress app provided by Bitnami package, but I manually installed each WordPress in each folder on the LAMP instance. (In addition to WordPress 6.6.1, which I installed myself, all versions PHP 8.x, MariaDB 10.x… provided by AWS are the latest versions.)
Thank you in advance for your comment.