There are 3 issues present in the default Apache and PHP 8 configuration on Windows.
- 500 Error when trying to upload files (plugins, media, etc)
- Temp folder missing/not configured
- (minor) Xdebug entries filling up
php\error.log
All 3 of these could be resolved with changes to the default setup along with providing user configuration through the Local app.
Issue 1: 500 Error
The apache\site-error.log
contains entries like the following:
[Thu Aug 18 20:30:45.242297 2022] [fcgid:warn] [pid 27196:tid 1240] [client 127.0.0.1:63542] mod_fcgid: read timeout from pipe, referer: SITE_ADDRESS/wp-admin/
[Thu Aug 18 20:30:45.243267 2022] [core:error] [pid 27196:tid 1240] [client 127.0.0.1:63542] End of script output before headers: admin-ajax.php, referer: SITE_ADDRESS/wp-admin/
[Thu Aug 18 20:33:46.742199 2022] [fcgid:warn] [pid 27196:tid 1240] [client 127.0.0.1:65462] mod_fcgid: HTTP request length 134700 (so far) exceeds MaxRequestLen (131072), referer: SITE_ADDRESS/wp-admin/plugin-install.php
As you can see, the default configuration only allows a 128KB upload. This is insufficient for Wordpress admin due to the size of Plugins, Themes, and the like. Additionally, many media files exceed that size.
Issue 2: Temp folder
When an upload does succeed, it gives an error on the page about the temp folder. This is because it’s not configured within PHP.
[19-Aug-2022 00:49:10 UTC] PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
Issue 3: Xdebug logging
By default, PHP is configured to load Xdebug with the mode set to debug
. This is a nuisance if we have no interest in debugging. In my case, my local site is being used for configuration and design purposes before using it on a live site. I don’t have a need for debugging, profiling, tracing, etc. Instead, it just continuously floods the log with entries such as the following.
[19-Aug-2022 00:26:28 UTC] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(
[19-Aug-2022 00:26:30 UTC] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 127.0.0.1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(
[19-Aug-2022 00:26:31 UTC] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 127.0.0.1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(
[19-Aug-2022 00:26:31 UTC] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(
...
[19-Aug-2022 00:29:12 UTC] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: ::1:9000 (from HTTP_X_FORWARDED_FOR HTTP header), localhost:9000 (fallback through xdebug.client_host/xdebug.client_port) :-(
This resulted in the PHP entries being hidden hundreds of lines in, such as the Warning in Issue 2 as well as important ones such as the Fatal error and stack trace that was caused by Wordpress.
[19-Aug-2022 00:55:40 UTC] PHP Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in D:\Local-Sites\sitename\app\public\wp-admin\includes\class-bulk-upgrader-skin.php:156
Resolutions
- Edit
(SITE_FOLDER)\conf\php\php.ini.hbs
a. In theif os.windows
section, add values forsys_temp_dir
andupload_temp_dir
. Example:
b. Add/edit the value forupload_max_size
. Optionally, adjust thepost_max_size
as well. - Edit
(SITE_FOLDER)\conf\apache\modules.conf.hbs
and add/edit the following. The value is bytes. It should be equal to or lesser than theupload_max_size
from php.ini. I added it to the end of my config.
<IfModule mod_fcgid.c>
FcgidMaxRequestLen 51200000
</IfModule>
- (optional) Configure Xdebug in
(SITE_FOLDER)\conf\php\php.ini.hbs
a. If it’s not wanted at all, comment out the entire section (prefix with a semicolon -;
)
b. If it should just be silenced with close to 0 overhead, turn it off withxdebug.mode=off
c. If it’s wanted, but the log keeps giving Time-out errors, change the port number to match your site. You can also change themode
to any valid value as listed in the Official Documentation
- Restart the site.
Recommendations
There needs to be a way, or multiple ways, to configure these values that are a problem from the start. All of them were missing for me (except for the Xdebug section), so I assume they all need to be added. It would be preferable if all were implemented, but being able to change it at the site level would be sufficient.
- Change the default Apache and PHP configurations during the install/deploy process before starting the site.
php.ini.bs
sys_temp_dir
andupload_temp_dir
- Set to the system temp folder.upload_max_size
should be set to a reasonable value, or set it to matchpost_max_size
.- Default Xdebug to
xdebug.mode=off
. - Set
xdebug.port
to match the deployed site’s value – the same one found inroute.SITE_DOMAIN.conf
apache\modules.conf.hbs
- Add the
<IfModule mod_fcgid.c>
block and setFcgidMaxRequestLen
to the same or lesser value ofupload_max_size
inphp.ini.hbs
, but represented in bytes. Official Documentation
- Add the
- Provide the option to set the values (paths and sizes) in the “New Site Defaults” in Preferences.
- Provide the option to re-configure at the site level. A new tab or section can be added as shown. If changes are made and saved, inform the user to restart the site.
- Add a way to open the config files directly in Notepad (or whatever the system text editor is) similar to the “Go to site folder” link. If you want to go extra, add an option in “Preferences” to select an editor. For instance, I use Notepad++ instead of regular Notepad.
- The options can be links, or a dropdown can be added for “Configuration” with “php.ini.bs”, “modules.conf.hbs”, etc. as options.
- It can be in the application menu similar to the “Reveal…” options and use the currently selected site to determine which one to open. Disable the menu options if one isn’t selected (no local sites, not on the “Local sites” screen).