Categories

Changing Default DocumentRoot Folder To Custom Location

Most Apache and PHP setups expect all DocumentRoot folders to exist under a certain path, that already has PHP, directory permissions, security, and other configurations implemented and enabled under it (via httpd.conf and included *.conf files). Normally, placing a website outside this path would require more then just updating the VirutalHost’s DocumentRoot path, but also re-implementing all those other configurations for the new location in the website’s VirtualHost file.

Luckily, under Windows there is an easier way to accomplish the above by simply using “Junction Points”, and linking out of the normal DocumentRoot folder to whatever other location (folder) you’d like (using something very similar to Linux’s ln links).

2. A website’s DocumentRoot folder is of the form:C:\WampDeveloper\Websites\primary.domain.name\webroot\

3. PHP is enabled under all paths of the form:C:\WampDeveloper\Websites\*\webroot\

Without modifying or adding to the existing configuration, you can use an NTFS “Junction Point” to make a link between an outside folder and either the website’s entire containing folder or the website’s “\webroot” (DocumentRoot) folder.

2. Then from the command line (WampDeveloper’s System Tab, Command Line button) execute (all on one line):mklink /j C:\WampDeveloper\Websites\www.example.com\webroot D:\Sites\www.example.com\

*Note that D:\Sites\www.example.com\ has to already exist.

3. Do not modify the VirtualHost with the new path; everything remains as-is.

This way you’ll have your real D:\Sites\www.example.com\ folder (where the files reside) and a link to that folder from C:\WampDeveloper\Websites\www.example.com\webroot (which is what WampDeveloper and its configuration will operate through).

Notes –

“Junction Points” only work between local drives of the system and OS (between local volumes), and will not link to networked drives or remote shares.

It is also not usually possible to directly link the folders of websites, nor the database folder, to a NAS device.

To use network shares, you would need to change Apache’s account from “LocalSystem” to an account that has network share access. Under Windows, while “LocalSystem” can access TCP/IP, it does not have permissions to access network shares.