Visit Jeremy's Blog.
Go Back > Linux Answers > Networking
User Name


By FuzzieDice at 2005-01-18 15:54
Using Windows Directories for Default Apache 2 Web Site
by Tika Carr (aka Fuzzie Dice)

License and Preamble

This is in ASCII text format and released with the GPL license found at If anyone wants to convert this into a HOWTO in DocBook format and distribute it, feel free to do so, as long as you keep my name in the credits somehow, as the original author, please. :) Modifications are welcome, of course.


This document will show you how to get the Apache 2 server to use your Windows partition directories INSTEAD OF the default Apache 2 directory. This is ONLY if you meet the following conditions:

- You will NOT need anyone accessing your web server from
the Internet (and have your firewall set that way).

- You are on a single-user machine (not on a network).

- You will be using Apache 2 and your windows sub-directory
only for developing web sites before you upload them to
your hosting provider.

This is NOT for intra net, Internet, or other server use as these settings probably won't work and might confuse things in those cases. This document will help you set up 'localhost' (your local server) to point to a windows directory (and cgi-bin in that directory) and make it usable so that when you go to http://localhost/ or http://localhost/cgi-bin/ in your browser, you'll be pulling in pages from the windows partition and not Apache 2's /var/www directory.

This setup was done using the Mandrake 10.0 distribution and Webmin via Firefox web browser. I'll be covering the direct-edit (probably faster) way to set this up and the Webmin steps in case you'd rather do it that way.

This is good for those who dual-boot and use both Windows and Linux on the same computer and on the same hard drive. This gives you the best of both worlds, as you can then share data on one partition (which I will refer to as win_d, with win_c being the Windows OS partition).

What You Need

You'll need to have the Apache 2 server installed, plus all the associated files, Perl modules, etc. Usually this is done for you in Mandrake 10.0 so you don't have to do anything. However, Webmin is NOT installed by default so if you plan to use that method of configuration, you'll need to go into your package manager and find it, then install it yourself (most package managers let you do a search for packages). You'll also need to know your path to your html directory on your Windows partition. For this example, I'll be using /mnt/win_d/html as the directory where web files are stored. This equates to D:\html on the Windows side of things.

Be sure you also have at least an index.html file with some text in it in your /mnt/win_d/html directory. This way you know for sure when you have accessed this directory. Create also a cgi-bin directory and put another index.html file in that with slightly different wording so that you can tell the difference between it and the main directory. This you'll need so that when we test the server, we know it's working.

Setup Via Configuration Files (Faster Method)

If you'd like to do this quick and easy, just start a shell and at the shell prompt, type: su then after that type in your root password (nothing will be echoed to the console). Once logged in as root:

Step 1:

Type: cd /etc/httpd/2.0/conf

Now use your favorite text editor to edit the httpd.conf file. Be sure there is a line somewhere in the file that says:

Include conf/vhosts/Vhosts.conf

If there isn't one, add one and save the file.

Step 2:

At the shell prompt, type: cd vhosts

Use your favorite text editor to edit the Vhosts.conf file. Type in the following lines at the end of the file. Be very sure you got everything correct! Or better yet, cut and paste these lines into the text file. When done, save the file.

DocumentRoot /mnt/win_d/html
ServerName localhost
Options FollowSymLinks
DirectoryIndex index.html index.htm default.html default.htm
<Directory "/mnt/win_d/html">
allow from all
order allow,deny
Options FollowSymLinks
DirectoryIndex index.html index.htm
<Directory "/mnt/win_d/html/cgi-bin">
allow from all
order allow,deny
Options ExecCGI FollowSymLinks IncludesNOEXEC
AllowOverride AuthConfig FileInfo Indexes Options
DirectoryIndex index.html index.htm index.php index.cgi
AccessFileName htaccess.cfg
Alias /cgi-bin/ /mnt/win_d/html/cgi-bin/

Step 3:

At the shell prompt, type: /etc/init.d/httpd restart

Now point your browser to http://localhost/ and you should see your /mnt/win_d/html/index.html file. Next try http://localhost/cgi-bin/ and you should see your /mnt/win_d/html/cgi-gin/index.html file.

You should be all set up at this point.

Using Webmin For Setup

Step 1:

In your web browser, point to http://localhost:10000/ and then log into the server using 'root' for a username and your root password.

Step 2:

Click on Servers at the top, then click the Apache icon. At the bottom, find a box labeled 'Create New Virtual Server' and fill in as follows (leave all other items at default):

Specific address:
Add name virtual server (if needed): UNCHECK!
Listen on address (if needed): UNCHECK!
Document root: /mnt/win_d/html
Server name: localhost
Click the Create button.

Step 3:
Click on the new virtual server icon and select Document Options. Leave all at default except:

Document root: /mnt/win_d/html
All users accessible (be sure it's selected)
Per-directory options file: Select radio button by text box and type: htaccess.cfg
Directory Options: Select radio button by 'Selected below'. Leave all radio buttons at 'no' except: follow symbolic links: yes
Click the Save button.

**** NOTE: ****
We use 'htaccess.cfg' instead of .htaccess because Windows by nature does not allow use of dot-files. All files in Windows normally MUST have a filename and an extension. I've seen dot-files created under Windows but I don't recommend it, just in case.

Step 4:

Click the Directory Indexing Icon. In Directory Index Files add the following, one item per line.


You MAY want to add in the Files to Ignore box: htaccess.cfg
Click the Save button.

Step 5:

In the virtual server page, go to the box named 'Create Per-Directory, Files or Location Options and be sure the Type is 'Directory'. Type in this path and click the 'Create' button: /mnt/win_d/html

Step 6:

Click on the new directory, then the Access Control icon. In Restrict Access, click on the radio button 'allow then deny'. Under it, in the Action, find "Allow" in the drop down box. Leave 'Condition' at "All Requests". Click Save button when done.

Step 7:

Click the Document Options icon and then be sure the radio button is on 'Selected below'. Leave all options at 'no' EXCEPT set 'follow symbolic links' to 'yes'. Click Save button when done.

Step 8:

Click the Directory Indexing icon and under Directory Index files, type in (one item per line):


You MAY want to add in the Files to ignore box: htaccess.cfg
Click the Save button.

Step 9: Setting Up cgi-bin

Go back to the main server page and click on the virtual host icon for localhost. Then click on the Aliases and Redirects icon. Add the following:

From box: /cgi-bin/
To box: /mnt/win_d/html/cgi-bin/

Note that there MUST be a slash / before AND after the directory names!

Step 10:

In the 'Create Per-directory, files or location options', set Type to 'Directory' and use /mnt/win_d/html/cgi-bin/ for the path. Click the Create button.

Step 11:

Click on the icon for the new cgi-bin directory entry then click on the Access Control Icon. Set Restrict Access to 'Allow then Deny' and then be sure under it reads 'allow all requests' (select 'allow' from drop down box, etc.) Click the Save button when done.

Step 12:

Click the Document Options Icon. Click the radio button next to 'Selected below'. Leave all options to 'no' except the following:
Execute CGI Programs
Follow symbolic links
Server-side includes

Select Options file override to 'Selected below' and UNCHECK 'Hostname access control'. Click the Save button when done.

Step 13:

Click the Directory Indexing Icon. In the Directory index file box, enter the following (one item per line):


You MAY want to add in the files to ignore box: htaccess.cfg
Click the Save button when done.

Step 14:

At the top of the page, you'll see some tabs. Click on the one marked 'Apply Changes'. Then click 'Stop Apache' and then 'Start Apache'. Be sure to allow the browser to fully reload and stop before you click on a tab.

Now point your browser to http://localhost/ and you should see your web server page on /mnt/win_d/html. Point your browser to http://localhost/cgi-bin/ and you should see your page stored on /mnt/win_d/html/cgi-bin


Now you should be able to share your web files between Windows and Linux. You don't have to use an FTP server to upload your files if using Mandrake 10.0 which automatically mounts win_d. You can just write the files directly to /mnt/win_d/html or whatever directory and then try it in your browser.


All times are GMT -5. The time now is 11:12 PM.

Main Menu

Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration