Windows 上的 apache 虚拟目录配置帮助

发布于 2024-07-09 00:28:19 字数 460 浏览 19 评论 0原文

我通过 Xampplite 在 Windows XP 上运行 Apache,并且可以使用帮助配置我的虚拟目录。 这是我希望在我的开发盒上执行的操作:

  1. xampp htdocs 目录之外
  2. 我希望我的源文件位于本地计算机上的 我可以通过 http://myproject
  3. 我本地网络上的其他人可以访问 my.ip.address/myproject 上的项目,
  4. 使 localhost 保持指向 xampp 的 htdocs 文件夹,以便我可以轻松添加其他项目。

我有 1 & 2 通过编辑Windows主机文件,并在xampp的apache\conf\extra\httpd-vhosts.conf文件中添加虚拟目录来工作。 我不知道如何在不搞乱4的情况下完成3。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

泼猴你往哪里跑 2024-07-16 00:28:19

弄清楚了:使用 Alias 作为 #3,而不是 VirtualHost,因此:

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>

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>
把昨日还给我 2024-07-16 00:28:19

完成您的需求清单。

1)建立目录:

mkdir c:\xampp\sites\myproject

2) 编辑 c:\windows\system32\drivers\etc\hosts 使其包含以下行:

127.0.0.1        我的项目

并将以下内容添加到 c:\xampp\apache\conf\extra\httpd-vhosts.conf:

 NameVirtualHost myproject:80 

    <虚拟主机我的项目:80> 
    文档根目录 c:/xampp/sites/myproject 
    选项索引 FollowSymLinks 包括 ExecCGI 
     允许覆盖全部 
    订单允许、拒绝 
    允许所有   
     
  

3) 将以下行添加到 c:\xampp\apache\conf\httpd.conf 的末尾:

 别名 /myproject/ "/xampp/sites/myproject/" 

    <目录“/xampp/sites/myproject”> 
    允许覆盖无 
    选项 无 
    订单允许、拒绝 
    允许所有 
     
  

4) 将 DocumentRoot、Directory 等保留在 c:\xampp\apache\conf\httpd.conf 中以完成此操作。 作为参考,这些行将是:

 DocumentRoot“/xampp/htdocs” 

    <目录/> 
     选项 FollowSymLinks 
     允许覆盖无 
     订单拒绝、允许 
     所有人都否认 
     

    <目录“/xampp/htdocs”> 
     选项索引 FollowSymLinks 包括 ExecCGI 
     允许覆盖全部 
     订单允许、拒绝 
     允许所有 
     
  

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>
软糖 2024-07-16 00:28:19

首先启用:LoadModule alias_modulemodules/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>

在 WAMP 2.2 上测试及其工作:http://localhost/ddd

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

空城旧梦 2024-07-16 00:28:19

在 httpd.conf 中添加以下几行,并作必要的修改:

<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>

重新启动 Apache 服务器后,这对我的 (Windows) XAMPP 安装非常有效。 我必须添加“要求全部授予”,但除此之外它与上面的答案几乎相同。

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.

寄人书 2024-07-16 00:28:19

NameVirtualHost myproject:80
< 虚拟主机 myproject:80 >
< /目录>

必须是:

NameVirtualHost myproject:80
< 虚拟主机 myproject:80 >
<强>< /虚拟主机>

打招呼;)

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

Must be:

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

greets ;)

睫毛上残留的泪 2024-07-16 00:28:19

解决了问题。 它缺少目录标签。

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>

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>
聚集的泪 2024-07-16 00:28:19

以最简单的方式和更少的步骤解决问题
无需创建虚拟主机,只需更改目标目录的位置即可。

这是我所做的配置:
我是通过编辑 C:/xampp/apache/conf/httpd.conf 文件来完成的
我在 httpd.conf 文件中所做的更改
之后添加了这个脚本
ScriptAlias /cgi-bin/ "C:/xampp/apache)/"

别名 /projectXYZ "C:/pathtomyproject"

选项 索引 FollowSymLinks MultiViews ExecCGI
允许覆盖全部
订单允许、拒绝
允许所有

Pathtomyproject = 项目的完整路径

并更改了文档根目录的 url
DocumentRoot " C:/pathtomyproject "

现在通过停止服务器来重新启动 Apache 服务器。
我已经停止了 Apache 服务器,然后再次启动了 Apache 服务器。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文