I looked everywhere to change DocumentRoot on Apache to no avail

19,087

Solution 1

A configuration like this should work:

DocumentRoot "C:/www"
<Directory "C:/www">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

Don't forget to restart the server after you have made any changes to your httpd.conf file. I would also try to temporary remove any existing .htaccess file located in the C:/www folder.

To check that the syntax of your configuration file is correct use the -t option:

httpd -t

You can also check the logs/error.log to get a better description of what went wrong.

References

Installing Apache 2.2 on Microsoft Windows

Solution 2

Firstly change the httpd.conf file

DocumentRoot "c:/www"
<Directory "c:/www">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

then open the "\conf\extra\httpd-vhosts.conf" file.

<VirtualHost *:80>
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
</VirtualHost>

To

<VirtualHost *:80>
    DocumentRoot "C:\www"
</VirtualHost>

Finally restart your apache web server and you are good to go..

Share:
19,087
poetryrocksalot
Author by

poetryrocksalot

Updated on June 11, 2022

Comments

  • poetryrocksalot
    poetryrocksalot almost 2 years

    I don't know what I am doing wrong but I can't change the directory of my localhost files with Apache. I tried all kinds of things with httpd.conf, including changing "Order allow,deny" to "Require all granted". It still doesn't work.

    I'm running Windows 7 64-bit and I'm trying to get Apache to work but all solutions so far have not helped me change DocumentRoot due to error 403.

    Here is the httpd.conf

    Here is my error log since the latest service restart

    The Apache2.4 service is restarting. The Apache2.4 service has restarted. m_winnt:notice [pid5304:tid 468] AH00424: Parent: Received restart signal -- Restarting the server.
    [Mon Sep 22 22:37:25.315061 2014] [ssl:warn] [pid 5304:tid 468] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
    [Mon Sep 22 22:37:25.315061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00455: Apache/2.4.10 (Win32) OpenSSL/1.0.1h configured -- resuming normal operations
    [Mon Sep 22 22:37:25.315061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00456: Apache Haus VC9 Server built: Jul 15 2014 20:34:18
    [Mon Sep 22 22:37:25.315061 2014] [core:notice] [pid 5304:tid 468] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
    [Mon Sep 22 22:37:25.317061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00418: Parent: Created child process 3648
    [Mon Sep 22 22:37:26.075104 2014] [ssl:warn] [pid 3648:tid 344] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
    [Mon Sep 22 22:37:26.265115 2014] [mpm_winnt:notice] [pid 6612:tid 348] AH00364: Child: All worker threads have exited.
    [Mon Sep 22 22:37:26.372121 2014] [ssl:warn] [pid 3648:tid 344] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
    [Mon Sep 22 22:37:26.375121 2014] [mpm_winnt:notice] [pid 3648:tid 344] AH00354: Child: Starting 64 worker threads.
    [Mon Sep 22 22:43:06.157556 2014] [autoindex:error] [pid 3648:tid 1052] [client ::1:53336] AH01276: Cannot serve directory C:/Apache24/htdocs/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
    
  • poetryrocksalot
    poetryrocksalot over 9 years
    This is the error I got from that: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
  • Cyclonecode
    Cyclonecode over 9 years
    Try removing you current configuration file and copy the original one (don't know the location of this on windows though) to the same location, then add the above directive (change www to localhost), save the file and then restart your server.
  • poetryrocksalot
    poetryrocksalot over 9 years
    Doesn't work. Does my directory have to be inside my apache installation?
  • Cyclonecode
    Cyclonecode over 9 years
    No that shouldn't be necessary, are you running apache as administrator? I think you should try to find a nice guide on how to best setup and configure apache on the windows platform. One more thing that comes to mind is that you should check so you don't have any virtualhost configuration that messes things up: stackoverflow.com/questions/89118/…
  • poetryrocksalot
    poetryrocksalot over 9 years
    I gave up. I'm going to find an alternative that is widely used on Windows. I'm also going to stick with using the default htdocs folder.