Apache won't start with spaces in pathname in httpd.conf (even with quotes)
Asked Answered
P

6

6

Problem

Apache won't start if there are spaces in the pathname in a virtual host configuration.

The usual solution is to just wrap the pathname in double quotes, but that doesn't fix it.

I WANT to have spaces in my pathname, so changing to dashes or what not isn't really an option.

The VERY same configuration as below without spaces works.

Sample

<VirtualHost *:80>
    DocumentRoot "C:/Users/Patrick/Google Drive/Projects/My Project"
    ServerName local.example.com
    ServerAlias local.example.com
    <Directory "C:/Users/Patrick/Google Drive/Projects/My Project">
    Options Indexes FollowSymLinks ExecCGI Includes
        AllowOverride All
        Order allow,deny
        Allow from all
        <IfModule mod_php5.c>
            php_admin_flag engine on
            # choose the one you want:
            # This is for E_ALL & ~E_STRICT & ~E_DEPRECATED
            # php_admin_value error_reporting 22527
            # This is for E_ERROR
            php_admin_value error_reporting 1
        </IfModule>
    </Directory>
</VirtualHost>
Pilatus answered 20/2, 2013 at 21:33 Comment(2)
I know this is old, but I just wanted to say that your method works fine for me on Linux.Drescher
Rename project folder? (Yes, linux is not windows...)Scarcely
P
11

did you try DocumentRoot "C:/Users/Patrick/Google\ Drive/Projects/My\ Project" ?

Pursuit answered 20/2, 2013 at 21:35 Comment(2)
That did the trick! I'll accept in 10 minutes when it lets me.Pilatus
Well, I spoke too soon. Apache DOES start, but then I get a 403 when trying to pull the site up in the browser.Pilatus
C
1

I got it working by using DOS 8.3 paths:

c:/users/patric~1/google~1/projec~1/myproj~1

You can see the DOS path by using dir /x on the command line.

Craggy answered 26/8, 2017 at 3:30 Comment(0)
R
0

If you are still searching for a solution you might try creating a junction that lets you relocate the contents of the root folder in a path with spaces. I did this and it works seamlessly.

You need Junction from Microsoft. I think you can create junctions without it but it is harder.

Create a apache_root.bat file to pass commands to junction.exe and reuse it if you delete the junction and need to recreate it:

"G:\SysinternalsSuite\junction.exe" "G:\UniServerZ\www\test" "G:\Google Drive\test"
  1. The first string is the path to juction.exe. I think you can write only "junction.exe" if the .bat file is in the same folder;
  2. The second string is the path to the juction folder. In my case this "test" folder is created;
  3. The third string is the source of the junction folder. In my case this "test" folder exists and has sub folders.

I use Uniform Server which is portable and has the root folder "www" inside the UniServerZ folder. Every time i update the server i delete the whole UniServerZ folder and run the .bat file to recreate the junction folder "test".

Of course the source folder is not deleted when you delete the junction. Beware of SymLinks that i see mentioned in your config file they do delete the source folder. I almost screwed up my Windows deleting a symbolic link.

Rudie answered 3/7, 2014 at 15:40 Comment(0)
M
0

Put the directory path in double quotes, for example:

DocumentRoot  "C:\Users\Touhid Mia\OneDrive\xxx"
<Directory  "C:\Users\Touhid Mia\OneDrive\xxxxx">
Metrist answered 28/11, 2014 at 9:45 Comment(1)
What does this even mean?Craftwork
S
0

I had the same problem when dropbox changed my folder name from E:\Dropbox to E:\Dropbox (Completa Content), and in my document root it looked like this: DocumentRoot E:/Dropbox, and when I changed it to E:/Dropbox (Completa Content), gave errors. After several attempts, I realized that it was just putting double quotes DocumentRoot "E:/Dropbox (Completa Content)" and it worked

Syncrisis answered 4/12, 2020 at 19:3 Comment(0)
E
0

On Apache 2.4.54 on Windows 10, I ended up using double backslashes in quotes:

Alias /testing2022/ "D:\\Other Projects\\Testing 2022\\"

<Directory "D:\\Other Projects\\Testing 2022\\">
   Require all granted
</Directory>
Enenstein answered 8/11, 2022 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.