apache on windows virtual directory config help
Asked Answered
H

7

21

I'm running Apache on Windows XP via Xampplite, and could use help configuring my virtual directory. Here's what I'm hoping to do on my dev box:

  1. I want my source files to live outside of the xampp htdocs dir
  2. on my local machine I can access the project at http://myproject
  3. others on my local network can access the project at my.ip.address/myproject
  4. keep localhost pointing to the xampp's htdocs folder so I can easily add other projects.

I've got 1 & 2 working by editing the windows hosts file, and adding a virtual directory in xampp's apache\conf\extra\httpd-vhosts.conf file. I don't immediately see how to do 3 without messing up 4.

Hannie answered 6/11, 2008 at 16:29 Comment(0)
H
33

Figured it out: use Alias for #3, instead of VirtualHost, thus:

Alias /myproject "C:/path/to/my/project"
<Directory "C:/path/to/my/project">
  Options Indexes FollowSymLinks MultiViews ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
Hannie answered 6/11, 2008 at 16:29 Comment(1)
For anyone unsure, this can go straight after <Directory "D:/XAMPP/htdocs">...stuff...</Direcory> in the httpd.conf file for the default site root. Worked for me perfectly. And don't forget to restart ApacheHirundine
G
12

To accomplish your list of needs.

1) Make the directory:

mkdir c:\xampp\sites\myproject

2) Edit c:\windows\system32\drivers\etc\hosts so it contains this line:

127.0.0.1         myproject

and add the following to c:\xampp\apache\conf\extra\httpd-vhosts.conf:

  NameVirtualHost myproject:80

  <VirtualHost myproject:80>
  DocumentRoot c:/xampp/sites/myproject
  Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
  Order allow,deny
  Allow from all  
  </Directory>

3) Add the following lines to the end of c:\xampp\apache\conf\httpd.conf:

  Alias /myproject/  "/xampp/sites/myproject/"

  <Directory "/xampp/sites/myproject">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  </Directory>

4) Leave DocumentRoot, Directory, etc in c:\xampp\apache\conf\httpd.conf alone to accomplish this. For reference these lines would be:

  DocumentRoot "/xampp/htdocs"

  <Directory />
   Options FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
  </Directory>

  <Directory "/xampp/htdocs">
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
   Order allow,deny
   Allow from all
  </Directory>
Griffey answered 6/11, 2008 at 16:29 Comment(0)
B
2

First enable: LoadModule alias_module modules/mod_alias.so

<IfModule alias_module>
  Alias /ddd "D:/prj/customer/www"

  <Directory "D:/prj/customer/www">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride all
    Order allow,deny
    Allow from all
  </Directory>
</IfModule>

Tested on WAMP 2.2 and its working: http:// localhost/ddd

Boding answered 6/11, 2008 at 16:29 Comment(0)
R
1

In httpd.conf add the following lines, mutatis mutandis:

<IfModule alias_module>
    Alias /angular-phonecat "C:/DEV/git-workspace/angular-phonecat"
</IfModule>

<Directory "C:/DEV/git-workspace/angular-phonecat">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride all
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

This worked great on my (Windows) XAMPP installation after restarting the Apache server. I had to add the "Require all granted", but otherwise it is pretty much the same as the above answers.

Radii answered 6/11, 2008 at 16:29 Comment(0)
T
0

resolved the issue. it was missing the directory tag.

NameVirtualHost myproject:80
<VirtualHost myproject:80>
    DocumentRoot "D:/Solution"
    <Directory "D:/Solution">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>    
</VirtualHost>
Tablecloth answered 6/11, 2008 at 16:29 Comment(0)
M
0

NameVirtualHost myproject:80 < VirtualHost myproject:80 >
< /Directory >

Must be:

NameVirtualHost myproject:80 < VirtualHost myproject:80 >
< /VirtualHost >

greets ;)

Margit answered 6/11, 2008 at 16:29 Comment(0)
E
-1

Problem resolved in a simplest way and less steps No Need of creating virtual host just change the location of target directory.

Here's what i have done for configuration: I've done it by editing the C:/xampp/apache/conf/httpd.conf file Changings that I have done in httpd.conf file Added this script right after ScriptAlias /cgi-bin/ "C:/xampp/apache)/"

Alias /projectXYZ "C:/pathtomyproject" Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny Allow from all

Pathtomyproject = Complete path of project

And changed the url of Document Root DocumentRoot " C:/pathtomyproject "

Now restart the Apache Server by stopping the server. I have stopped Apache server, and then again started the Apache Server.

Source: http://bytespedia.blogspot.com/2013/12/creating-virtual-directory-in-apache.html

Eudemonism answered 6/11, 2008 at 16:29 Comment(4)
Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.Furmenty
as i was unable to attach picture so i have added link to complete description. @FurmentyEudemonism
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Aparicio
@Aparicio I have edited my comment and added the essential part of the solution/link.Eudemonism

© 2022 - 2024 — McMap. All rights reserved.