Apache + PHP in paths with accented letters
- by Álvaro G. Vicario
I'm not able to run a PHP enabled web site under Apache on Windows XP if the path to DOCUMENT_ROOT contains accented letters. I'm not referring to the script file names themselves but to any folder in the path components.
I have this virtual host definition:
<VirtualHost *:80>
ServerName foo.local
DocumentRoot "E:/gonzález/sites/foo"
ErrorLog logs/foo.local-error.log
CustomLog logs/foo.local-access.log combined
<Directory "E:/gonzález/sites/foo">
AllowOverride All
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
If I save the file in ANSI I get a syntax error: DocumentRoot must be a directory
If I save the file in Unicode I get another syntax error: Invalid command '\xff\xfe#', perhaps misspelled or defined by a module not included in the server configuration (looks like it's complaining about the BOM)
If I save the file in BOM-less UTF-8 Apache works fine and it serves static files with no apparent issue...
... however, PHP complaints when loading any *.php file (even an empty one):
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'E:/gonzález/sites/foo/vacio.php' (include_path='.;C:\Archivos de programa\PHP\pear') in Unknown on line 0
I decided to try the 8+3 short name of the directory (just a test, I don't want to use such a workaround):
<VirtualHost *:80>
ServerName foo.local
DocumentRoot "E:/GONZLE~1/sites/foo"
ErrorLog logs/foo.local-error.log
CustomLog logs/foo.local-access.log combined
<Directory "E:/GONZLE~1/sites/foo">
AllowOverride All
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But I get the same behaviour:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'E:/gonzález/sites/foo/vacio.php' (include_path='.;C:\Archivos de programa\PHP\pear') in Unknown on line 0
While there're obvious workarounds (use plain ASCII in all directory names or create NTFS junctions to hide actual names) I can't believe that this cannot be done. Do you have more information about the subject?
My specs include 32 bit Windows XP Professional SP3, Apache/2.2.13 and PHP/5.2.11 running as Apache module (but I've noticed the same issue in another box with Windows Vista and PHP/5.3.1).