1

I am transferring a site that was built on Windows XAMPP to a server running Ubuntu 24.04 (Noble Numbat), Apache 2.4.62, and PHP 7.4.33. Everything is working fine, except PHP files containing spaces anywhere in the path are not found.

I have confirmed the file does actually exist by running

ls "/var/www/html/tempdir/test name.php"

which returns the file path.

I looked through the log files and am pretty sure I have nailed down where the hiccup is.

[core:trace5] [pid 14742:tid 14827] protocol.c(713): [client 127.0.0.1:35246] Request received from client: GET /tempdir/test%20name.php HTTP/1.1
[http:trace4] [pid 14742:tid 14827] http_request.c(435): [client 127.0.0.1:35246] Headers received from client:
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246]   Host: localhost
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246]   User-Agent: Wget/1.21.2
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246]   Accept: */*
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246]   Accept-Encoding: identity
[http:trace4] [pid 14742:tid 14827] http_request.c(438): [client 127.0.0.1:35246]   Connection: Keep-Alive
[authz_core:debug] [pid 14742:tid 14827] mod_authz_core.c(815): [client 127.0.0.1:35246] AH01626: authorization result of Require all granted: granted
[authz_core:debug] [pid 14742:tid 14827] mod_authz_core.c(815): [client 127.0.0.1:35246] AH01626: authorization result of <RequireAny>: granted
[core:trace3] [pid 14742:tid 14827] request.c(360): [client 127.0.0.1:35246] request authorized without authentication by access_checker_ex hook: /tempdir/test name.php
[proxy:trace2] [pid 14742:tid 14827] proxy_util.c(2457): [client 127.0.0.1:35246] *: fixup UDS from proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost/var/www/html/tempdir/test name.php: fcgi://localhost/var/www/html/tempdir/test name.php (/run/php/php7.4-fpm.sock)
[proxy_fcgi:trace1] [pid 14742:tid 14827] mod_proxy_fcgi.c(76): [client 127.0.0.1:35246] canonicalising URL //localhost/var/www/html/tempdir/test name.php
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(123): [client 127.0.0.1:35246] AH01060: set r->filename to proxy:fcgi://localhost/var/www/html/tempdir/test%20name.php
[proxy:trace2] [pid 14742:tid 14827] proxy_util.c(2625): [client 127.0.0.1:35246] *: using default reverse proxy worker for fcgi://localhost/var/www/html/tempdir/test%20name.php (no keepalive)
[proxy:debug] [pid 14742:tid 14827] mod_proxy.c(1465): [client 127.0.0.1:35246] AH01143: Running scheme fcgi handler (attempt 0)
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(1078): [client 127.0.0.1:35246] AH01076: url: fcgi://localhost/var/www/html/tempdir/test%20name.php proxyname: (null) proxyport: 0
[proxy_fcgi:debug] [pid 14742:tid 14827] mod_proxy_fcgi.c(1087): [client 127.0.0.1:35246] AH01078: serving URL fcgi://localhost/var/www/html/tempdir/test%20name.php
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(2797): AH00942: FCGI: has acquired connection for (*:80)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3242): [client 127.0.0.1:35246] AH00944: connecting fcgi://localhost/var/www/html/tempdir/test%20name.php to localhost:8000
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3309): [client 127.0.0.1:35246] AH02545: fcgi: has determined UDS as /run/php/php7.4-fpm.sock (for localhost:8000)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3450): [client 127.0.0.1:35246] AH00947: connecting /var/www/html/tempdir/test%20name.php to /run/php/php7.4-fpm.sock:0 (localhost:8000)
[proxy:debug] [pid 14742:tid 14827] proxy_util.c(3832): AH02823: FCGI: connection established with Unix domain socket /run/php/php7.4-fpm.sock (localhost:8000)
[proxy_fcgi:error] [pid 14742:tid 14827] [client 127.0.0.1:35246] AH01071: Got error 'Primary script unknown'
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(572): [client 127.0.0.1:35246] Headers from script 'test%20name.php':
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(575): [client 127.0.0.1:35246]   Status: 404 Not Found
[proxy_fcgi:trace1] [pid 14742:tid 14827] util_script.c(654): [client 127.0.0.1:35246] Status line from script 'test%20name.php': 404 Not Found
[proxy_fcgi:trace4] [pid 14742:tid 14827] util_script.c(575): [client 127.0.0.1:35246]   Content-type: text/html; charset=UTF-8

I am probably wrong, but I think the bug is when file proxy_util.c (line 3450) connects to the socket it keeps the URL tail formatted for TCP with the %20. So how can I fix this? Restructuring the site is not an option.

It seems like this person was having the same trouble: FastCGI URL cannot contain spaces

6
  • 2
    Don't use spaces in file names. It will give you headaches. Convert them to dashes or underscores. Commented Jul 25, 2024 at 17:48
  • "Restructuring the site is not an option" - By saying that you mean that if you cannot solve this problem, you will just stay on Xampp then? Commented Jul 26, 2024 at 13:05
  • Looks like you are running in a proxy mode. First, do you need that mode? Are you just using it for TLS termination, or something else? If just a simple thing like TLS termination, would you be open to trying something else for that, such as Nginx, and let that terminate and proxy to Apache. Commented Jul 26, 2024 at 13:09
  • Otherwise, maybe you could monkey around with an htaccess rule that looks for a space and rewrites it. And then you can just find all files with a space in their name and rename them, which isn't that hard. The application can still send users to the old URLs, although in the long run I would change that. Commented Jul 26, 2024 at 13:12
  • @ChrisHaas I can not change the folder structure to existing media files as their locations are defined by an instance of owncloud server. This intranet site is referencing the owncloud data directly readonly. The proxy mode is for reddis memcache for the owncloud instance. Luckily, the media files still resolve with spaces in the path. After sleeping on it, I should be able to move the php files to a location with no spaces. More than anything, I thought I was running into a config problem and not a foundational limitation. Commented Jul 26, 2024 at 21:20

2 Answers 2

1

It turns out that "The PHP Handler was using PHP-FPM, and the issue with the spaces appears to be a limitation therein. I was able to view the pages with spaces with PHP-FPM disabled. I have disabled PHP-FPM on your account on PHP 7.3."

Sign up to request clarification or add additional context in comments.

1 Comment

Why is most of it quoted? What is the explanation?
0

I had a similar issue where my Apache + PHP-FPM setup suddenly wouldn't allow files to have white spaces in them. Turns out there's a regression described here: https://github.com/php/php-src/issues/15246

The workaround described says you need to add this to your Apache config:

ProxyFCGISetEnvIf "true" SCRIPT_FILENAME "%{unescape:%{SCRIPT_FILENAME}}"

This worked for me, but tread carefully. It might break other stuff, and probably needs to be removed when the regression is fixed.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.